Vb net 表單切換

請問我有兩個form ,form1 and form2 ,在form2裡 怎麼enable or disable form1的元件??

已更新項目:

我也是這樣寫的,可是沒效果.

Private Sub Button3_Click()

Button2.Enabled = False

Form2.Show

End Sub

Private Sub Form2_Disposed()

Form1.Button2.Enabled = True

End Sub

2 個已更新項目:

有3個form ,form1 ,form2 ,form3

form1 有一button1

Private Sub Button1_Click()

Form2.Show

End Sub

Private Sub Button2_Click()

Form2.Button2.Enabled = False

Form3.Show

End Sub

Private Sub Form3_Disposed()

Form2.Button2.Enabled = True

End Sub

form2可以enable or disable form1 的元件,但form3fm卻不能

3 個已更新項目:

有Form3_Disposed()這個事件阿,我是希望form3 close時 form2 的button被enable.

奇怪的是form2 可以控制form1的元件,form3卻不能控制form2的元件.....

2 個解答

評分
  • XiDeww
    Lv 4
    6 年前
    最佳解答

    假設Form1有一個Button

    (Form1的程式碼)

    Private Sub Command1_Click()

    Form2.Show

    End Sub

    (Form2有一個Button的程式碼)

    Private Sub Command1_Click()

    Form1.Command1.Enabled = False

    End Sub

    Form1.Command1.Enabled = False

    Form1.物件名稱.屬性

    你是指這個嗎?

    2014-03-31 20:53:23 補充:

    Form3_Disposed()

    沒有這個事件,所以說你等於把它寫成了一個Sub副程式

    在Form3再丟一個叫做Button3的按鈕

    Private Sub Button_Click()

    Call Form3_Disposed

    End Sub

    才會去觸發

    Private Sub Form3_Disposed()

    Form2.Button2.Enabled = True

    End Sub

    這個程序

    2014-03-31 20:54:23 補充:

    我是VB6

    所以我不知道 .Net有沒有 Form3_Disposed()這個程序@@

    2014-03-31 22:17:12 補充:

    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Form2.Show()

    End Sub

    End Class

    2014-03-31 22:17:19 補充:

    Public Class Form2

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Form1.Button1.Enabled = False

    Button1.Enabled = False

    Form3.Show()

    End Sub

    End Class

    2014-03-31 22:17:40 補充:

    Public Class Form3

    Private Sub Form3_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed

    Form2.Button1.Enabled = True

    End Sub

    End Class

    剛測試form3關閉時,可以啟動Form2按鈕哦

    2014-03-31 22:19:15 補充:

    你應該是按鈕命名的問題吧@@???

    參考資料: Me, Myself, Myself, d, d, d, d
  • 匿名使用者
    6 年前

    下面的網址能回答你的問題

    ▶▶http://*****

還有問題?馬上發問,尋求解答。