472,811 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 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 17041
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: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.