Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

In one of my Form derived classes, there is a line of code that causes the designer to show an error, but it is fine at run time. I thought I could use the "if( !this.DesignMode ) test to only run the line of code at run time, but this does not work and I still get the design time error. But if I say if ( this.DesignMode ), it evaulates to false both at design time and run time, so it looks like this property is always false, at design time and at run time.

 

There must be something special about using the DesignMode property in a Form that I am missing. Do you have any other suggestions as to how I should deal with code that seems to break my use of the designer? Its only by trial & error that I was able to narrow down to the line of code that breaks the designer, and I am still not sure what is the problem with the line of code that is causing the problem.

 

thanks

Bryan

Posted

i have a similar issue in the General section of these forums.

I was told that you can't use this property in Sub New()... although i haven't tested it yet i have a feeling that you are experiencing the problem i'm about to have when i get home from school today..

check out my post to get more info

i'm not lazy i'm just resting before i get tired.
Posted

I am using "if not me.designmode" in a property setter and it works fine.

 

Where/When exactly is your "designmode" checker called?

.nerd
Posted

I was accessing a static data member which (normally) gets instantiated when the main application is run. This data member was designed to manage serialization for the class in question. The data being accessed was the form position and location. So I can move this initialization to the onLoad event. It seems to me to make sense to expect a form to get its position and location at construction time, but in design mode of course, there is no serialization, so that is what caused me to look into the designmode property to prevent the class deserializing its data at design time. Normally, I would expect the class itself to be automatically deserialized, but Forms cannot be serialized, so that is why I separated the data from the form.

 

But I understand your point that most anything I might want to do in a constructor can be done at a later time.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...