473,320 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 4453

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Thomas | last post by:
Hy dudes, I have a strange problem. I dynamically create an IFrame with JavaScript and then fill in some content. Afterwards I want to switch to designMode. There the trouble starts. In Mozilla...
2
by: Lecture Snoddddgrass | last post by:
Hi, When I create a UserControl-derived object, I often expose various public properties. One of the things that I hate about the WinForms designer is that if I decide to embed one of these...
3
by: Bob Rivers | last post by:
Hi, I'm trying to build a web page where the user can insert text dinamically. When the user hits a button, a new text box is created and the user can insert text into it. It's working nice...
5
by: Larry | last post by:
I'm currently using designMode in a page, and it's been working for IE6 on Windows, but I'm hearing complaints that it's not working on IE6 on Mac. I had done some research on this before deciding...
29
by: Charles Law | last post by:
Further to my issue about user controls, I have a problem with DesignMode. Here is the project hierarchy: MainApp |_ Project1 |_ SubProject (UserControl) SubProject has a default constructor...
1
by: Paul W | last post by:
I'm having trouble detecting whether my Control is in DesignMode. I'm deriving a class from TreeView; Public Class ExplorerView Inherits TreeView ... End Class
4
by: Kyjan | last post by:
Greetings! In doing some research, I've learned that some other people have had problems with Me.DesignMode not working correctly when it's used in a user control that is placed on another form....
1
by: Larry | last post by:
I have a page which uses designMode which is working on IE but I'm having a devil of a time getting it to work in Safari 3. Is there any working code example of designMode which works on Safari? ...
3
by: Sagaert Johan | last post by:
Hi I stumbled to this : I have a form and in the contructor i put if (this.DesignMode) return; other code here The IDE designer throws an exception and points to a line in the 'other
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.