How can I get Text property to initialize to the objects name at design time?
Posted
by cyclotis04
on Stack Overflow
See other posts from Stack Overflow
or by cyclotis04
Published on 2010-06-10T17:07:11Z
Indexed on
2010/06/10
17:13 UTC
Read the original article
Hit count: 212
When you add a label to the form from the toolbox, its text defaults to the item's name (label1
, label2
, etc). How can I make this happen with a custom control? So far, I have the following, which allows me to change the text through the property window:
private string _text;
[BrowsableAttribute(true)]
public override string Text
{
get { return _text; }
set
{
_text = value;
lblID.Text = _text;
}
}
Apparently the above code works as is, but I'm not sure why. Does Text
default to the object's name automatically? The question still stands for other properties which don't override Text
.
© Stack Overflow or respective owner