Hi
I just discovered something interesting while I was creating my library
If you are using the last release of Microsoft Visual Studio.NET 2003, create a new component, and in the component constructor add the following:
if(this.DesignMode) System.Windows.Forms.MessageBox.Show("Design Mode On");
Now, compile the code, place the component on a form, close the form and open it again.
The results are: nothing will happen :):)
The same code will work every ware else in the component in design mode, except the constructor, in the constructor it will work if it get changed to the following:
if(!this.DesignMode) System.Windows.Forms.MessageBox.Show("Design Mode On");
And this means “show a message if it is not in design time”, when in reality it is!
If anyone have access to the bug reporting DB of VS.NET 2003, and that is a bug, please report it.

A component does not recognize if it is in design mode!, a bug?
Guillermo Serrato - MSFT
1- Add a property (bool) to your component.
2- Add an event to your component to be raised when the prop value changes.
3- Create a designer for your component.
4- Override Initialize, assign the property on your component to True
5- Catch the event in your component and execute your dependent workload there.
HTH!
abc4567
The DesignTime property simply reflects the DesignTime state of the ISite assigned to the component. If one has not yet been assigned, it returns false.
Jerrill
public override ISite Site
{
get
{
return base.Site;
}
set
{
base.Site = value;
if(this.DesignMode)
{
// code
}
}
}
I still have no idea what ISite is doing exactly, but the code seams to work on initialization :) :)
Thanks again
Raj
To see when ISite becomes interesting at runtime, drop a timer on a form and look at the code generated. The timer will be created with the following code:
timer1 = new Timer(components);
The components parameter is a container, and this constructor on Timer sites the timer to a container. This is important, because when you close the form there is nothing that would Dispose the timer (and it would continue to tick forever, because each tick "wakes" it up so it won't GC).
Another way sites are used at runtime is for a primitive form of styles: if you take all of your forms and site them to a container, and that container offers AmbientProperties as a service, you can control the look and feel of all the forms at once. This is how Visual Studio gets all of its dialogs to use the same font.
Mincemaker