graeme g wrote:
ii
i've been developing some usercontrols... and sudden the property designmode
no longer works.. if i test it value at designtime it always comes back
false...
i've made a work around
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
b_designMode = true;
else
b_designMode = false;
b_designMode to a private bool in the class
anyone know why it stopped working?
I'm guessing that it's because you're testing it in your control's
constructor. The DesignMode property always returns false until the
control's window handle is set, which happens some time before the Load
event.
You should put all long-running code in the control's OnLoad method.
Just initialize everything to null in the constructor. DesignMode will
give a correct value in the OnLoad method:
public MyControl : UserControl
{
public MyControl()
{ ... set everything to null ... }
protected override void OnLoad(EventArgs e)
{
if (!this.DesignMode)
{
... do user control set-up here ...
}
}
}