Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a user control and I have tested the value of DesigMode in different parts of source, but never get the true value and is always false.

I read that the first place that it is set to true is in load event, then I created the following event but still get false.

this.Load += new System.EventHandler(this.ReportDesigner_Load);

private void ReportDesigner_Load(Object sender, EventArgs e)
{
IsRunningByDeveloper = this.DesignMode;
}

I don't know what is wrong , I have also checked other solutions in all the sites but none of them worked .
I also used license manager as below but still in runtime mode.
C#
if (System.ComponentModel.LicenseManager.UsageMode == LicenseUsageMode.Designtime)
                IsRunningByDeveloper = true;



Any suggestions would be appreciated
Posted

1 solution

The DesignMode property indicates whether the control is rendering in the design mode of Visual Studio

What is Control's DesignMode property and how to use it?[^]
 
Share this answer
 
Comments
albert sh 16-Aug-13 12:18pm    
I Appreciate your comment, I thought designmode is useful when you want to detect when the project is running through Visual studio or not, Is there any property to show that?
Maarten Kools 16-Aug-13 13:17pm    
Not really. But it's safe to assume you run the debug version of your software from within Visual Studio. So you can test in your code using #if DEBUG. Like so:

#if DEBUG
bool IsRunningByDeveloper = true;
#else
bool IsRunningByDeveloper = false;
#endif
albert sh 16-Aug-13 16:21pm    
Thanks for your reply, but your solution must be set manually,
I found a command to check it:
System.Diagnostics.Debugger.IsAttached

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900