推 kgjojo:感謝~~! 06/19 23:37
※ 引述《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