By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,650 Members | 1,976 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,650 IT Pros & Developers. It's quick & easy.

User control Text property not appearing in Properties window

P: n/a
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
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Why not just override the parents' Text property? Maybe it is having
problems with two Text properties. Just a guess though.

"Rob Richardson" <no*******@n2net.net> wrote in message
news:#K**************@TK2MSFTNGP14.phx.gbl...
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

Nov 16 '05 #2

P: n/a
Use a declaration like this.

[EditorBrowsable(EditorBrowsableState.Always), Browsable(true),
DesignerSerializationVisibility(DesignerSerializat ionVisibility.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" <no*******@n2net.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.