PC Review


Reply
Thread Tools Rate Thread

Adding Event Handlers to Inherited Controls

 
 
stuppi
Guest
Posts: n/a
 
      20th Dec 2007
I often create classes that inherit from standard controls in order to handle
certain events in a consistent manner. Being a novice propononet of
encapsulation, I add the event handlers in the constructor of the derived
class. However, as many of you have probably discovered, this can create
problems with WinForms and the VS forms designer if those event handlers rely
on runtime conditions. Can anyone suggest a "designer safe" place to add the
event handlers within the derived class?

 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      21st Dec 2007
The System.Windows.Forms.Control (and all inherited classes, therefore)
class has a property called "DesignMode" which is a boolean value. If you
don't want to run code in the designer, use a test for DesignMode to prevent
it from running.

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

"stuppi" <(E-Mail Removed)> wrote in message
news:C8677178-99F1-4130-B486-(E-Mail Removed)...
>I often create classes that inherit from standard controls in order to
>handle
> certain events in a consistent manner. Being a novice propononet of
> encapsulation, I add the event handlers in the constructor of the derived
> class. However, as many of you have probably discovered, this can create
> problems with WinForms and the VS forms designer if those event handlers
> rely
> on runtime conditions. Can anyone suggest a "designer safe" place to add
> the
> event handlers within the derived class?
>



 
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
Need help with adding Controls and event handlers at runtime martin.zackrisson@gmail.com Microsoft Excel Programming 0 27th Dec 2006 05:36 PM
Need help with adding Controls and event handlers at runtime martin.zackrisson@gmail.com Microsoft Excel Programming 0 27th Dec 2006 05:36 PM
adding event handlers for windows controls Peter Foot [MVP] Microsoft Dot NET Compact Framework 2 22nd Apr 2004 09:01 PM
Inherited event handlers joe Microsoft C# .NET 1 5th Jan 2004 11:07 AM
Cascading Inherited Forms Keydown Event Handlers Tappy Tibbons Microsoft Dot NET Framework Forms 0 11th Aug 2003 06:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:53 PM.