User control properties--can't override base

D

David Veeneman

I'm having trouble implementing a UserControl base property in a user
control that I am writing. My user control wraps a group box that contains
several radio buttons. I want to wire the user control's Text property to
the group box's Text property, like this:

[Browsable(true)]
public override string Text
{
get { return groupBox1.Text; }
set { groupBox1.Text = value; }
}

The property works fine at design time--I can set the user control's Text
property from a host form, and the value I type in appears as the caption
for the user control's group box. But the value is lost when the host
application is launched. At runtime, the group box shows its default value.

I can fix the problem by changing the name of the user control property from
"Text' to something else, like 'Caption'. Then the design time value
persists just fine to run time. But I'd really like to use the name 'Text'
for the user control property, to remain consistent with .NET conventions.

Is this problem common? What do I need to do to be able to use the name
'Text'? Thanks in advance for your help.
 

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