Can I set the value of a custom control programmatically in control project designer?
Let's say I have a label in a custom control. In the constructor I set it's text value.
The label doesn't refresh. It does so only when in a client form.
How can I update this label on the custom control itself p开发者_开发问答rogrammatically ?
Make the text of the label accessible as a property of the Control: (The getter is not necessary for your case, so you can leave that out if you don't want it)
public string LabelText
{
get
{
return Label1.text;
}
set
{
Label1.text = value;
}
}
This way the property will even show up in the designer of the control, or you can set it programmatically lik this:
MyControl.LabelText = "text";
精彩评论