VS IDE check if Design Mode is active

0.00 avg. rating (0% score) - 0 votes

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;
}

Reference: http://devlicio.us/blogs/derik_whittaker/archive/2006/09/25/Determining-if-the-.Net-IDE-is-in-Design-Mode.aspx

0.00 avg. rating (0% score) - 0 votes
ToughDev

ToughDev

A tough developer who likes to work on just about anything, from software development to electronics, and share his knowledge with the rest of the world.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>