What's my Mode?

  • Thread starter Thread starter Pertti Karjalaine
  • Start date Start date
P

Pertti Karjalaine

What might be the best way to detect in code whether (C#)
system is in design mode or running? In other words, how
to tell the system if I want something to happen in a
control constructor when I am dropping the control onto a
form, but don't want it to happen when the control is
initialized in a running form.

Thanks!
 
Never you mind... The answer to the question below is
something like this:

private bool designMode =
Application.ExecutablePath.ToLower().IndexOf("devenv.exe")
 
Hi

You are deriving from the Control Class to create your own
Custom Control right!!! Now the Control class itself is
derived from the System.ComponentModel.Component Class and
this class offers a DesignMode property which you can use

hth

regards,

sr
 
Thank you for the response. DesignMode is a good
candidate, but it has a few limitations.

If I understand the .NET documentation properly,
DesignMode will have a "correct" value only if the
control has an ISite associated with it. If this is not
the case, the property will always be false.

So, if I want the control to be aware of its environment
(design/running) without requiring anything "extra" from
its container, DesignMode would not be a good choice.

Pertti
 
Back
Top