button click not firing it's method VB.NET

2019-04-14 01:55发布

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?

标签: vb.net button
3条回答
戒情不戒烟
2楼-- · 2019-04-14 02:11

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.

查看更多
forever°为你锁心
3楼-- · 2019-04-14 02:26

Change the declaration like this:

Private Sub button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
查看更多
beautiful°
4楼-- · 2019-04-14 02:31
  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".

The handler should now be again associated with your buttons click event.

查看更多
登录 后发表回答