Text removed at startup on custom control

CrookDawg

Freshman
Joined
Jan 7, 2004
Messages
31
i made a custom button control just for fun but when i start the test program, the text i entered in the designer disappears from the button. in the designer, it works. i found out that for some reason vs.net is not adding a me.button.text property under the code properties of my control. the text property is declared overrides in my control. if i manually add the control via code in the load procedure and add text to it there, it works no problem. anyone know what how to convince the designer to add my property when i change it at design time?

thanks for your help
-matt
 
are you using mybase.text or not???

I have found the same problem, and reverted to using my own text property.

the pig..
 
PiggyBank1974 said:
are you using mybase.text or not???

I have found the same problem, and reverted to using my own text property.

the pig..


i don't belive so. i have the property declared shadows (otherwise it doesn't accept the declaration) i have had this work on some of my other controls. ill try to see what is different about this one. thanks
 
here is the project. the problem is with the control ButtonEx. the rest are just unfinished controls that i was experimenting with as i am sorta new to programming. thanks for your help
 

Attachments

Last edited by a moderator:
I would remove your local _text variable and use the base class' version and then change the property to
Visual Basic:
    <Category("Appearance"), Browsable(True), DefaultValue(""), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
    Public Overrides Property Text() As String
        Get
            Return MyBase.Text
        End Get
        Set(ByVal Value As String)
            MyBase.Text = Value
            Invalidate()
        End Set
    End Property 'Text
The DefaultValue("") attribute is optional but the DesignerSerializationVisibility attribute is the key to the problem here.
 
it worked!! (not that i doubted you) ill have to read up on DesignerSerializationVisibility when i get the time. thanks for your help (again)
 
Back
Top