Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

User control Text property not appearing in Properties window

278 views
Skip to first unread message

Rob Richardson

unread,
Mar 11, 2005, 3:45:07 PM3/11/05
to
Greetings!

I just developed a little control I've wanted for ages. It links a textbox
and a label into a single control. At first, I gave it a property named
LabelText and another named BoxText. Both of them happily appeared in the
Properties window when I dropped my control onto another control. But then
I remembered that Microsoft wants to standardize on using the property name
"Text" for things that look like text. I decided that the text box's text
was the important thing in the control, so I changed the name of BoxText to
Text. But now the Text property does not appear in the Properties window!
What do I have to do to get it to show up? I think it's related to the fact
that the UserControl class has a Text property already.

Here's the definition of the Text property:

public new string Text
{
get
{
return theTextBox.Text;
}
set
{
theTextBox.Text = value;
}
}

I tried using "override" instead of "new", but that didn't work either.

Thanks very much!

RobR


Peter Rilling

unread,
Mar 11, 2005, 4:01:19 PM3/11/05
to
Why not just override the parents' Text property? Maybe it is having
problems with two Text properties. Just a guess though.

"Rob Richardson" <notr...@n2net.net> wrote in message
news:#KmDzqnJ...@TK2MSFTNGP14.phx.gbl...

Tim Wilson UNDERSCORE AT PERIOD

unread,
Mar 11, 2005, 4:02:19 PM3/11/05
to
Use a declaration like this.

[EditorBrowsable(EditorBrowsableState.Always), Browsable(true),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible),
Bindable(true)]
public override string Text {get; set;}

The UserControl is overriding the Control.Text property and adding
attributes to hide it from the properties window, editor, etc. These
attributes are being inherited and thus you are not seeing the property
appear.

--
Tim Wilson
.Net Compact Framework MVP

"Rob Richardson" <notr...@n2net.net> wrote in message

news:%23KmDzqn...@TK2MSFTNGP14.phx.gbl...

0 new messages