Form Designer oddities: "Custom" TextBox

Arokh

Centurion
Joined
Apr 11, 2006
Messages
124
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?
 
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
 
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.
 
Back
Top