Re: [.NET] 關閉動態(run time)產生的表單的問題

看板Visual_Basic作者 (重新出發....)時間16年前 (2009/06/19 09:29), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《kgjojo (Ahh..Fresh Meat!)》之銘言: : 請輸入專案類型(網站專案或者應用程式專案):VB2008 : 大家好~~想請教一個問題,就是我在Form1按下一個button後, : 會產生一個新表單(myForm),語法大約如下 : Dim myForm As New Form : With myForm : 中間設定一些新表單的屬性 : End With : Dim myButton As New Button : With myButton : .Parent = myForm : 其他屬性 : End With : 請教各位,該怎麼設計才能在按myButton的時候,關閉myForm呢? 先寫一個Sub模擬Button_Click Private Sub Button_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) CType(CType(sender, Button).Parent, Form).Close() End Sub 然後在你的 With myButton 到 End With之間加上一行 AddHandler myButton.Click AddressOf Button_Click 降子應該就可以了 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.160.50.161

06/19 23:37, , 1F
感謝~~!
06/19 23:37, 1F
文章代碼(AID): #1AEkdstE (Visual_Basic)
文章代碼(AID): #1AEkdstE (Visual_Basic)