Catching Click Events on a Custom Control

  • Thread starter Mac via DotNetMonster.com
  • Start date
M

Mac via DotNetMonster.com

Hi all,

In my VB windows application, I have created a User Control that contains a
few buttons and a text box. This control is then placed on several forms.

What I would like to do is capture the click event of each specific button
within the control at the form level, but I am not sure how this is achieved.

The events that I can see are directly linked to the whole control that is on
the form. How do I add an event handler at the form level for the controls
within this control?

Any help is appreciated.

regards,

Mac
 
M

Mac via DotNetMonster.com

Have solved it - Intellisense actually confused me. This what I did:

AddHandler Me.Grid33.WinButton1.Click, AddressOf grid33_winbutton1_click

Where grid33 is my custom control. The confusing thing was when I typed "Me."
it only brought up a list of events for the form. I actually realised I could
put in the name of the control I wanted from another piece of sample code.

Strike one for Intellisense.

regards,

Mac
 
C

Chris

Mac said:
Hi all,

In my VB windows application, I have created a User Control that contains a
few buttons and a text box. This control is then placed on several forms.

What I would like to do is capture the click event of each specific button
within the control at the form level, but I am not sure how this is achieved.

The events that I can see are directly linked to the whole control that is on
the form. How do I add an event handler at the form level for the controls
within this control?

Any help is appreciated.

regards,

Mac

There may be another way, but how I've seen it done is that you have
your user control define an event:

Public Event XYZButtonClicked(...)

then when your button is clicked in your user control, you fire off your
event which your form can catch.

Good Luck
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top