VS IDE check if Design Mode is active
Useful when desining user controls – in order to make certain functionalities available in design mode but not in runtime and vice versa.
public bool IsInDesignMode()
{
bool returnFlag = false;
#if DEBUG
if (System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime)
{
returnFlag = true;
}
else if (Process.GetCurrentProcess().ProcessName.ToUpper().Equals(“DEVENV”))
{
returnFlag = true;
}
#endif
Debug.WriteLine(“IsInDesignMode returns ” + returnFlag.ToString());
return returnFlag;
}