我正在使用以下代码在运行时向窗体添加按钮:
Private Sub AddNewButton(ByVal btnName As String, ByVal btnText As String)
Dim myButtons As New VIBlend.WinForms.Controls.vButton
With myButtons
.Size = New Size(200, 60)
.Visible = True
.Location = New Point(55, 33)
.Text = btnText
.Name = btnName
.Font = New Font("Times New Roman", 12, FontStyle.Bold, GraphicsUnit.Point)
End With
AddHandler myButtons.Click, AddressOf btnName & "_Click"
btnsPanel.Controls.Add(myButtons)
End Sub
代码工作正常,但 Vb.net 不允许我使用变量AddressOf btnName & "_Click"
说分配 AddressOf 子过程AddressOf operand must be the name of method
,问题是我不知道要创建哪个按钮以及它将调用哪个过程,我想分配使用变量的 AddressOf 过程是否有可能或者我还有其他选择吗?