按钮单击不触发它的方法 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 13:31:59  来源:igfitidea点击:

button click not firing it's method VB.NET

vb.netbutton

提问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

  1. Go to the Forms designer.
  2. Select the Button.
  3. In the Properties Pane, bottom right by default, click the "Lightning Bolt" Icon.
  4. Find the "Click" entry.
  5. Click the small dropdown arrow to the right and select "button1_click".
  1. 转到表单设计器。
  2. 选择按钮。
  3. 在属性窗格中,默认右下角,单击“闪电”图标。
  4. 找到“点击”条目。
  5. 单击右侧的小下拉箭头并选择“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