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

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;
}
}
 
K

Kyle Kaitan

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

thanks,
- Kyle
 
R

Rob Oldfield

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;
}
}
 
L

Laurent

Hi,

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

[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top