Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have made my own Textbox class (with the standart .NET textbox inherited).

I added some properties etc..

 

Now I can select my textbox in the Controllist and put them on forms and also set the properties I created, which works fine.

 

But some of the properties change other properties.

For example:

If I set the TextInfo property (Is displayed when there is no text and disappears when the TextBox is focused), the property also sets the Text property in designer mode.

The program hasn't even run once.

 

Now if I run the program it is like I would have set the Text & TextInfo property to the same value, although I only want to set the TextInfo property at startup.

 

Is there any way to tell the designer to stop programatically changing other properties at designtime?

  • *Experts*
Posted

I believe you can use "this.DesignMode" or "Me.DesignMode" to check, and prevent, accidental writing of things like the Text property.

 

I've used that on classes that inherit from Form but should work for custom/user controls.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • Leaders
Posted

There are problems with checking Control.DesignMode for modified design-time behavior. I believe, but I'm not certain, that only the Form and top-level controls will have this property set to true (meaning it won't work as expected for controls contained in controls). I know I've had problems in the past with this.

 

Detecting design time has a few solutions.

[sIGPIC]e[/sIGPIC]

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