我创建了一个按钮,但是当我点击时无法让它运行msgbox(“点击”)..我做错了什么? 感谢。
Private Sub main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With mybut
mybut.AutoSize = True
mybut.Name = "delete-btn" & btn_number
mybut.Location = New System.Drawing.Point(500, 20)
mybut.Text = "Delete"
End With
End Sub
Private Sub mybut_Click(sender As Object, e As EventArgs)
MsgBox("Click")
End Sub
答案 0 :(得分:1)
点击按钮需要Handles
Private Sub mybut_Click(sender As Object, e As EventArgs) Handles mybut.Click
MsgBox("Click")
End Sub
如果是动态按钮,则需要add an event handler
AddHandler mybut.Click, AddressOf Me.mybut_Click