Arokh Posted May 28, 2008 Posted May 28, 2008 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? Quote
*Experts* Nerseus Posted May 30, 2008 *Experts* Posted May 30, 2008 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 Quote "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 snarfblam Posted May 30, 2008 Leaders Posted May 30, 2008 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. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.