PC Review


Reply
Thread Tools Rate Thread

Catching Click Events on a Custom Control

 
 
Mac via DotNetMonster.com
Guest
Posts: n/a
 
      11th Aug 2005
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


--
Message posted via http://www.dotnetmonster.com
 
Reply With Quote
 
 
 
 
Mac via DotNetMonster.com
Guest
Posts: n/a
 
      11th Aug 2005
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


--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200508/1
 
Reply With Quote
 
Chris
Guest
Posts: n/a
 
      11th Aug 2005
Mac via DotNetMonster.com wrote:
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
same sub, multiple control click events cj Microsoft VB .NET 12 29th Jun 2006 04:02 AM
catching events when you click on a seperate form =?Utf-8?B?Z2hvYmxleQ==?= Microsoft VB .NET 2 2nd Jun 2005 05:59 PM
Tab Control Click Events MikeC Microsoft Access VBA Modules 2 16th Sep 2004 12:22 PM
Tab Control and on click events. Mike Microsoft Access Forms 5 3rd Jun 2004 04:55 PM
Catching events in web form fired by user control Nick Lewis Microsoft ASP .NET 1 1st Aug 2003 01:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:03 PM.