按钮单击不触发它的方法 VB.NET
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16445877/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
button click not firing it's method VB.NET
提问by neknek mouh
Hello I'm having a problem with my button. When I click it, the button's not firing the method:
您好,我的按钮有问题。当我单击它时,该按钮不会触发该方法:
Private Sub button1_Click(sender As System.Object, e As System.EventArgs)
'Initialize the capture device
grabber = New Capture()
grabber.QueryFrame()
'Initialize the FrameGraber event
AddHandler Application.Idle, New EventHandler(AddressOf FrameGrabber)
button1.Enabled = False
End Sub
What am I missing in here?
我在这里缺少什么?
回答by IvanH
There should be something like
应该有类似的东西
Private Sub button1_Click(sender As System.Object, e As System.EventArgs) Handles button1.Click
or
或者
AddHandler button1.Click, AddressOf button1_Click
I suppose its vb.net and winforms. With VB6 or WPF is a solution little bit different.
我想它的 vb.net 和 winforms。使用 VB6 或 WPF 是一个有点不同的解决方案。
回答by Idle_Mind
- Go to the Forms designer.
- Select the Button.
- In the Properties Pane, bottom right by default, click the "Lightning Bolt" Icon.
- Find the "Click" entry.
- Click the small dropdown arrow to the right and select "button1_click".
- 转到表单设计器。
- 选择按钮。
- 在属性窗格中,默认右下角,单击“闪电”图标。
- 找到“点击”条目。
- 单击右侧的小下拉箭头并选择“button1_click”。
The handler should now be again associated with your buttons click event.
处理程序现在应该再次与您的按钮单击事件相关联。
回答by Joel Coehoorn
Change the declaration like this:
像这样更改声明:
Private Sub button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

