472,141 Members | 1,003 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,141 software developers and data experts.

DesignMode not working

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?

thanks

g
Aug 16 '06 #1
2 4343

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

Aug 16 '06 #2
Thanks for your help

I read that it doesn't work in the constructor... and I thought but it's not
in the constructor... but it turned out that I was calling a function in the
constructor which caused the problem...

It been one of those weeks...

:-)

"Bruce Wood" <br*******@canada.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
>
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 ...
}
}
}

Aug 16 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Lecture Snoddddgrass | last post: by
3 posts views Thread by Bob Rivers | last post: by
5 posts views Thread by Larry | last post: by
29 posts views Thread by Charles Law | last post: by
1 post views Thread by Paul W | last post: by
1 post views Thread by Larry | last post: by
3 posts views Thread by Sagaert Johan | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.