[英]Program stuck when trying to add new buttons after dynamical button is clicked
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Panel1.Controls.Clear()
Dim patiekalai = New Button()
Dim patiekalai1 = New Button()
Dim patiekalai2 = New Button()
Dim patiekalai3 = New Button()
Dim patiekalai4 = New Button()
Panel1.Controls.Add(patiekalai)
patiekalai.Location = New Point(0, 0)
patiekalai.Size = New Size(80, 50)
Panel1.Controls.Add(patiekalai1)
patiekalai1.Location = New Point(0, 50)
patiekalai1.Size = New Size(80, 50)
Panel1.Controls.Add(patiekalai2)
patiekalai2.Location = New Point(0, 100)
patiekalai2.Size = New Size(80, 50)
Panel1.Controls.Add(patiekalai3)
patiekalai3.Location = New Point(0, 150)
patiekalai3.Size = New Size(80, 50)
Panel1.Controls.Add(patiekalai4)
patiekalai4.Location = New Point(0, 200)
patiekalai4.Size = New Size(80, 50)
patiekalai.Image = Image.FromFile("../M/Karštieji patiekalai.jpg")
AddHandler patiekalai.Click, AddressOf Patiekalai_Click
patiekalai1.Image = Image.FromFile("../M/Salotos.jpg")
patiekalai2.Image = Image.FromFile("../M/Desertai.jpg")
patiekalai3.Image = Image.FromFile("../M/Užkandžiai.jpg")
patiekalai4.Image = Image.FromFile("../M/Sriubos.jpg")
End Sub
Private Sub Patiekalai(ByVal sender As System.Object, ByVal e As System.EventArgs)
Panel1.Controls.Clear()
Dim patiekalai5 = New Button()
Dim patiekalai6 = New Button()
Dim patiekalai7 = New Button()
Panel1.Controls.Add(patiekalai5)
patiekalai5.Location = New Point(0, 0)
patiekalai5.Size = New Size(80, 50)
Panel1.Controls.Add(patiekalai6)
patiekalai6.Location = New Point(0, 50)
patiekalai6.Size = New Size(80, 50)
Panel1.Controls.Add(patiekalai7)
patiekalai7.Location = New Point(0, 100)
patiekalai7.Size = New Size(80, 50)
End Sub
Private Sub Patiekalai_Click(ByVal sender As Object, ByVal e As EventArgs)
Throw New NotImplementedException
End Sub
End Class
I get 我懂了
Private Sub Patiekalai_Click(ByVal sender As Object, ByVal e As EventArgs)
Throw New NotImplementedException
End Sub
after program fails and stuck. 程序失败并卡住后。
I am trying to add new buttons after patiekalai button is clicked. 我尝试在单击patiekalai按钮后添加新按钮。
You will have to add a handler in code manually by using AddHandler
to attach the delegate. 您将必须使用AddHandler
附加委托来手动在代码中添加一个处理程序。
AddHandler patiekalai6.click, addressof Patiekalai_Click
for example. 例如。 you will need to add a handler like this for each of the buttons. 您将需要为每个按钮添加一个类似的处理程序。
Panel1.Controls.Add(patiekalai7)
patiekalai7.Location = New Point(0, 100)
patiekalai7.Size = New Size(80, 50)
AddHandler patiekalai7.click, addressof Patiekalai_Click
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.