Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How can I tell my form is being used in design time and not runtime?

Check the Form.DesignMode property. But note that when in Visual Inheritance mode (designing a derived form), your control's DesignMode property will be true when the base form's constructor gets executed in the design-time.

To workaround this, you could check if the application in which your control is running is not devenv.exe, as follows:

if ( Application.ExecutablePath.ToLower().IndexOf( "devenv.exe" ) > -1 ) 
{ 
// Then executing in Visual Studio .NET 
}

Contributed from George Shepherd's Windows Forms FAQ