R
Rob Richardson
Greetings!
A few days ago, I asked how to get a property named "Text" to appear in the
Properties window for a control I developed. It was being hidden by the
Text property of the UserControl class, which was being hidden. Someone was
kind enough to post code very similar to the following, which is what I'm
using:
[EditorBrowsable(EditorBrowsableState.Always),
Browsable(true),
// DesignerSerializationVisibility(DesignerSerializationVisibility.Visible),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
Bindable(BindableSupport.Yes)]
public override string Text
{
get
{
return lblMain.Text;
}
set
{
try
{
lblMain.Text = value;
}
catch (Exception ex)
{
throw;
}
}
}
The Text property is accessible in the Properties window. However, if I
drop one of these controls onto a form, change the Text property, save the
form, close it, and reopen it, the Text property has its default value
instead of what I just entered. If I look in InitializeComponent(), I don't
see the expected "this.MyControl.Text = "What It's Supposed To Be" " line.
I tried changing the DesignerSerializationVisiblity attribute as you see
above, but it didn't help. What do I have to do?
Thanks very much!
RobR
A few days ago, I asked how to get a property named "Text" to appear in the
Properties window for a control I developed. It was being hidden by the
Text property of the UserControl class, which was being hidden. Someone was
kind enough to post code very similar to the following, which is what I'm
using:
[EditorBrowsable(EditorBrowsableState.Always),
Browsable(true),
// DesignerSerializationVisibility(DesignerSerializationVisibility.Visible),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
Bindable(BindableSupport.Yes)]
public override string Text
{
get
{
return lblMain.Text;
}
set
{
try
{
lblMain.Text = value;
}
catch (Exception ex)
{
throw;
}
}
}
The Text property is accessible in the Properties window. However, if I
drop one of these controls onto a form, change the Text property, save the
form, close it, and reopen it, the Text property has its default value
instead of what I just entered. If I look in InitializeComponent(), I don't
see the expected "this.MyControl.Text = "What It's Supposed To Be" " line.
I tried changing the DesignerSerializationVisiblity attribute as you see
above, but it didn't help. What do I have to do?
Thanks very much!
RobR