Live Chat Icon For mobile
Live Chat Icon

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

Platform: WinForms| Category: Tips

Check the the property Form.DesignMode.

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 app in which your control is running is not devenv.exe, as follows:

string exePath = Application.ExecutablePath;
exePath = exePath.ToLower();
if(Application.ExecutablePath.ToLower().IndexOf('devenv.exe') > -1)
	// Then you are running in

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.