Composite controls don't persist data? (sorry, repost)

  • Thread starter Thread starter Kyle Kaitan
  • Start date Start date
K

Kyle Kaitan

Sorry, I hit enter before I finished writing the previous post... ignore
that one. :-)

====

all,

I made a composite control ("TitleBar") consisting of a Panel that in turn
holds an Image and a Label. The Text property of this control just gets or
sets the text in the Label; nothing fancy (see below).

At design-time, if I change the Text property of the control once it's in a
form, it appears fine. But if I close the designer and re-open it, the text
is gone. What gives?

Any help is appreciated. Thanks!

[Category("Appearance")]
[Description("The title text to be displayed.")]
[Browsable(true)]
public override string Text
{
get
{
return this.f_Label.Text;
}
set
{
this.f_Label.Text = value;
}
}
 
I forgot to mention this, but this is in .NET 2.0, if that makes any
difference.

thanks,
- Kyle
 
I don't understand exactly why (so maybe somebody else will expand) but I
had the same thing earlier on today. It's something to do with the fact
that 'Text' is an existing property, so you have to use MyBase.Text
something like (apologies, but I'm a VB type... hopefully this will
translate)....

In the Get...

Return MyBase.Text

In the Set....

MyBase.Text=Value
f_label.text=Value


Kyle Kaitan said:
I forgot to mention this, but this is in .NET 2.0, if that makes any
difference.

thanks,
- Kyle

Kyle Kaitan said:
Sorry, I hit enter before I finished writing the previous post... ignore
that one. :-)

====

all,

I made a composite control ("TitleBar") consisting of a Panel that in turn
holds an Image and a Label. The Text property of this control just gets or
sets the text in the Label; nothing fancy (see below).

At design-time, if I change the Text property of the control once it's in
a form, it appears fine. But if I close the designer and re-open it, the
text is gone. What gives?

Any help is appreciated. Thanks!

[Category("Appearance")]
[Description("The title text to be displayed.")]
[Browsable(true)]
public override string Text
{
get
{
return this.f_Label.Text;
}
set
{
this.f_Label.Text = value;
}
}
 
Hi,

I also made composite control with Text overridden and works fine, try to
add this attributes to the Text property.

[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
 
Back
Top