473,411 Members | 2,230 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,411 software developers and data experts.

if (this.DesignMode) return ; Not working

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
code" block .

Any reason why ?






Oct 20 '06 #1
3 17107
DesignMode is not usable in the constuctor; try putting this code (both
DesignMode and what you want to do) into a handler on the Load event.

Marc

Oct 20 '06 #2
Sagaert Johan wrote:
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
code" block .

Any reason why ?
Hi,

Because you're in the constructor of your object, it stands to reason that
DesignMode will *not* have a value... since you're only _just_ constructing
your object, nothing will have set DesignMode.

There's another way to do it, but I cannot remember off the top of my head.
Something to do with a license manager IIRC.

--
Hope this helps,
Tom Spink

Google first, ask later.
Oct 20 '06 #3
I usually have a base class like this for forms and user controls.

public class BaseDesignModeUserControl : UserControl
{
private static readonly bool isDesignMode;

static BaseDesignModeUserControl()
{
isDesignMode =
(System.Diagnostics.Process.GetCurrentProcess().Pr ocessName.IndexOf("devenv")
!= -1);
}
protected bool IsDesignMode
{
[DebuggerStepThrough]
get
{
return isDesignMode;
}
}

}
Sagaert Johan wrote:
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
code" block .

Any reason why ?
Oct 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Asad Khan | last post by:
It makes all the sense in the world, but its not working. Any idea why? Click the popup button to popup a new screen, and then click the print button on the popup (which doesn't do anything!). ...
1
by: nntp | last post by:
It works in IE and Opera, but not in NS. Demo: http://javascript.internet.com/games/mouse-bomb.html Code: <!-- TWO STEPS TO INSTALL MOUSE BOMB: 1. Copy the coding into a new file, save as...
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...
7
by: jammie_linux | last post by:
Hi, Please look at the following code. In my opinion, the value of "char *str" in the main function should not change even after calling the function "funct" and that's beacuse the "char *str" in...
4
by: Paul | last post by:
I added a textbox to a c# page and can access it with code behind but added a dropdown list by draging it on the page from the toolbar but when typing this. the dropdown id is not selectable and I...
2
by: graeme g | last post by:
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...
12
by: Sheldon | last post by:
#define UWORD2 unsigned short int typedef BYTE Boolean; Boolean evaluateBit(UWORD2 *value, int bitnumber); Boolean evaluateBit(UWORD2 *value, int bitnumber) { int one=1; return (one &(*value...
1
by: Phil Latio | last post by:
Can anyone tell me why:- class=\"$this->styleclass\" statement in the function generateHTML() (which is at very bottom) fails to pass the value "error" meaning I can't use the style class I...
2
by: ft310 | last post by:
forwardpath gets loaded with "http://rhodeisland-aa.org/tester/ meetings/disclaima.htm?mtgnum=764" At "pos = forwardpath.indexof("disclaima.htm") ;" This stops with the error...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.