-1
我想按我已編程方式創建一個按鈕,併爲它生成一個消息框(Visual Basic中) 這是生成按鈕的代碼:我該如何處理以編程方式爲按鈕創建的點擊事件?
Dim NodeButton As New Control
NodeButton.Name = "Button" & NodeID
NodeButton.BackColor = Color.Red
NodeButton.Text = NodeID
NodeButton.Size = New Point(ButtonSize, ButtonSize)
NodeButton.Location = New System.Drawing.Point(Xcoordinate, YCoordinate)
frmMain.Controls.Add(NodeButton)
NodeButton.BringToFront()
的[動態按鈕單擊事件處理程序(http://stackoverflow.com/questions/7375061/dynamic-button-click-event-handler) –
也有可能重複[這](HTTP://計算器.com/questions/7291461/how-do-i-create-an-event-handler-for-a-programmatically-created-object-in-vb-net)and [this](http://stackoverflow.com/問題/ 21642678/how-can-i-create-dynamic-button-click-event-on-dynamic-button-vb-net)和[this](http://stackoverflow.com/questions/14948332/how-to -make-a-click-event-for-runtime-created-controls-in-visual-basic-2010) –
谷歌你的標題和答案可能會在那裏爲你。 – Bugs