UserControl -- detecting designtime vs runtime

I have a UserControl I am developing.

How can I have it detect when it is in designtime vs runtime?  I want certain behavior at designtime.
LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?
 
AlexFMConnect With a Mentor Commented:
To be presize, we should talk about control's site (container) design mode, and not about control design mode. When control itself is in design mode, it's code is not running. However, control's site can be in design or runtime mode, in both cases control's code is executed, and control itself is in runtime mode.
0
 
AlexFMCommented:
if ( Site.DesignMode )
{
    // control is in design mode
}
0
 
Tom KnowltonWeb developerAuthor Commented:
What is the difference between:

if ( Site.DesignMode )
{
    // control is in design mode
}

and

if ( this.DesignMode )
{
    // control is in design mode
}


???
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
Tom KnowltonWeb developerAuthor Commented:
Let me ask you this.....for a User Control....I know that you can have Properties that you set at Design Time and they will affect the controls at design time.

For example....the Font property when clicked on shows a small little box with three dots   .  .  .    which when you click on the box it brings up a Font Dialog.

Is it possible to have a property that has the same thing....except when you click on the dots box  it  opens a CUSTOM Dialog box that I have created myself?   And then how would I tie that dialog box to the User Control ?
0
 
AlexFMCommented:
I think this.DesignMode called from control itself will always returns false when contrrol code is executed. When control is in design mode, it's code is not running, and there is no chance to get true.
When control is part of the form (container, site), control's site design mode may be true or false.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.