Home
Manage Your Code
Snippet: Check if Designtime or Runtime (DesignMode vs RuntimMode) (C#)
Title: Check if Designtime or Runtime (DesignMode vs RuntimMode) Language: C#
Description: Function checks if we're in DesignMode or Runtime mode Views: 102
Author: Max Young Date Added: 5/14/2008
Copy Code  
1public bool InDesignMode
2{
3	System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv") 
4}
5
Usage
if (InDesignMode())
{
	DoSomeDesignTimeOnlyProcess();
}
else
{
	DoSomeRuntiomeOnlyProcess();
}
Notes
DesignMode only works when a controls parent is currently open in the IDE - this code checks if the current process is the VD IDE. Change the process name as appropriate for other IDE environments,