I found this answer on Stackoverflow: DesignMode with NestedControls.
The best answer stated that, if you don't want to use reflection, and you want to check in the constructor whether you are in DesignMode, you should use something like:
bool inDesignMode = System.ComponentModel.LicenseManager.UsageMode == LicenseUsageMode.Designtime;
My Problem
To test this, I created a simple usercontrol with three Labels:
public MyUserControl()
{
InitializeComponent();
this.label1.Text = String.Format("Construction: DesignMode: {0}", this.DesignMode);
bool inDesignMode = System.ComponentModel.LicenseManager.UsageMode == LicenseUsageMode.Designtime;
this.label2.Text = String.Format("Construction: LicenseManager: {0}", inDesignMode);
}
private void Onload(object sender, EventArgs e)
{
this.label3.Text = String.Format("OnLoadDesignMode: {0}", this.DesignMode);
}
I also created a Form with this Usercontrol on it.
If I use the designer to show the Form, I see the following:
Conclusion: in the constructor you can't use DesignMode. However,you can use the LicenseManager
However, if I open the usercontrol in the designer, it seems like the constructor isn't even used!
So now I am a bit confused.