PC Review


Reply
Thread Tools Rate Thread

Custom controls and events

 
 
jlea
Guest
Posts: n/a
 
      14th Feb 2005
I've created a custom control based on TreeView and it handles several
events, such as Mousedown. I added this custom control to the toolbox in
another project, dragged the custom control to the form and everything works
as it should with the custom control responding to the mousedown event.

I also want to respond to the mousedown down event occuring in the custom
control inside of the form containing the custom control. Does anyone know
how to let the custom control respond to the event and then allow it's
parent/owner to get to the event?

Thanks.

Jon.


 
Reply With Quote
 
 
 
 
Ajay Kalra
Guest
Posts: n/a
 
      14th Feb 2005
Instead of taking this approach where you depend upon parent/child
relationship, why not use events? Fire an event from the control and if
parent wants to handle it, it will provide the handler and it will get
called. This keeps the coupling loose between control and the parent
and is more flexible than the approach you mentioned.

-----------
Ajay Kalra
(E-Mail Removed)

 
Reply With Quote
 
Rachel Suddeth
Guest
Posts: n/a
 
      14th Feb 2005
If the event is public, you can handle it wherever you want. Just like an
event on any other control. Both event handlers will be run each time the
MouseDown even fires.

"jlea" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I've created a custom control based on TreeView and it handles several
> events, such as Mousedown. I added this custom control to the toolbox in
> another project, dragged the custom control to the form and everything
> works
> as it should with the custom control responding to the mousedown event.
>
> I also want to respond to the mousedown down event occuring in the custom
> control inside of the form containing the custom control. Does anyone know
> how to let the custom control respond to the event and then allow it's
> parent/owner to get to the event?
>
> Thanks.
>
> Jon.
>
>



 
Reply With Quote
 
jlea
Guest
Posts: n/a
 
      15th Feb 2005
Thanks for the reply. I ended up creating a custom event passing information
along what I needed (a TreeNode) and that seemed to work very well. Can you
refire the mousedown event and then have the parent trap for the re-fired
mousedown event? It seems like that won't work since the control already has
a handler for the mousedown event.

"Ajay Kalra" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Instead of taking this approach where you depend upon parent/child
> relationship, why not use events? Fire an event from the control and if
> parent wants to handle it, it will provide the handler and it will get
> called. This keeps the coupling loose between control and the parent
> and is more flexible than the approach you mentioned.
>
> -----------
> Ajay Kalra
> (E-Mail Removed)
>



 
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
custom events in custom controls not appear in properties window Peted Microsoft C# .NET 0 25th May 2009 09:09 AM
custom events in custom controls not appear in properties window Peted Microsoft C# .NET 0 25th May 2009 09:09 AM
Custom controls and events Mark Microsoft VB .NET 2 17th Mar 2006 12:52 PM
Custom controls and events doron Microsoft C# .NET 0 4th Sep 2005 12:43 PM
Custom User Controls and dynamically created web controls events not firing Nicole Microsoft Dot NET Framework 0 25th Sep 2003 10:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:56 AM.