Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UserControl.Text not being serialised

Status
Not open for further replies.

misterstick

Programmer
Apr 7, 2000
633
GB
i have a control derived from UserControl.

one of the rocket scientists at microsoft decided that the Text property on a UserControl wasn't needed in the designer and would never be serialised, and so turned it off.

i've turned it back on again, and changing the value in the properties page changes the value in the designer.

for the life of me, though, i can't get it to serialise into the .designer.cs of forms that use it, so that closing the form and opening it again loses the value.

Code:
public class MyUserControl : UserControl
{
 [EditorBrowsable(EditorBrowsableState.Always)]
 [Browsable(true)]
 [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
 [Localizable(true)]
 public new string Text
 {
  // using a contained label to display text
  get { return label.Text; }
  set { label.Text = value; }
 }
}

any ideas?

mr s. <;)

 
Maybe change the method from Text to CustomText and set that property instead.

When someone puts in .Text="value" just make it set the CustomText...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top