C#自定义控件怎么去掉某个属性

2024-12-01 10:29:08
推荐回答(1个)
回答1:

比如你想改变Labelx的Text属性,不必将整个控件公开吧,只要添加一个访问LabelX.Text的属性就可以啊
[Category("自定义参数设置")]
[Description("获取/设置控件标题提示语控件")]
public LabelX Control_LableTitle
{
get
{
return this.m_ctrlLabel_SavePathTitle;
}
set
{
this.m_ctrlLabel_SavePathTitle = value;
this.lblSavePathTitle.Text = value.Text;
this.lblSavePathTitle.Font = value.Font;
this.lblSavePathTitle.ForeColor = value.ForeColor;
}
}
可以换成
[Category("自定义参数设置")]
[Description("获取/设置控件标题提示语控件")]
public string Control_LableTitle
{
get
{
return this.m_ctrlLabel_SavePathTitle.Text;
}
set
{
this.lblSavePathTitle.Text = value

}
}

如果还不行就将setter方法的那句代码改作用propertyinfo.Setvalue的方法更改控件在设计阶段的更改