我是编程新手,我需要一些非常基本的帮助..
我有一个带有 datagridview 和一个“插入”按钮的表单,可以打开一个弹出窗口(新表单)。此弹出窗口包含标签和文本框,以及 2 个按钮(插入和取消)。如何将事件处理程序添加到弹出窗口内的按钮?例如,如果用户单击“取消”,弹出窗口应该关闭。
这是我到目前为止的代码:
Public Sub InsertButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 处理 InsertButton.Click
Dim insertPopup As New Form
insertPopup.Size = New System.Drawing.Size(300, 400)
insertPopup.StartPosition = FormStartPosition.CenterScreen
insertPopup.Show()
Dim acceptButton As New Button
Dim cancelButton As New Button
acceptButton.Location = New System.Drawing.Point(100, 325)
acceptButton.Text = "Insert"
acceptButton.Size = New System.Drawing.Size(85, 24)
acceptButton.TabIndex = 1
cancelButton.Location = New System.Drawing.Point(190, 325)
cancelButton.Text = "Cancel"
cancelButton.Size = New System.Drawing.Size(85, 24)
cancelButton.TabIndex = 2
insertPopup.Controls.Add(acceptButton)
insertPopup.Controls.Add(cancelButton)
End Sub
谢谢你的帮助。