![](/img/trans.png)
[英]Get the property value set in the Designer from another property of a Custom Control
[英]Can I set the value of a custom control programmatically in control project designer?
假設我在自定義控件中有一個標簽。 在構造函數中,我設置它的文本值。
標簽不會刷新。 只有在采用客戶形式時才這樣做。
如何以編程方式在自定義控件本身上更新此標簽?
使標簽的文本作為Control的屬性可訪問:(對於您的情況,getter不是必需的,因此如果您不需要,可以將其保留)
public string LabelText
{
get
{
return Label1.text;
}
set
{
Label1.text = value;
}
}
這樣,屬性甚至會顯示在控件的設計器中,或者您可以通過編程方式設置它:
MyControl.LabelText = "text";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.