1,propfull
private bool deviceState=false;
[Browsable(true)]//設置這個屬性是可見的
[Category("自定義屬性")]//屬性的分組,類別的名稱
[Description("設備狀態")]//屬性的描述
public bool DeviceState
{
get { return deviceState; }
set
{
deviceState = value;
if (deviceState)
{
this.pic_start.Image = Properties.Resources.on__32綠色;
this.pic_stop.Image = Properties.Resources.off__32灰色;
}
else
{
this.pic_start.Image = Properties.Resources.on__32灰色;
this.pic_stop.Image = Properties.Resources.off__32紅色;
}
}
}
2,prop
[Browsable(true)]//設置這個屬性是可見的
[Category("自定義屬性")]//屬性的分組,類別的名稱
[Description("啟動綁定的PLC地址")]//屬性的描述
public string StartAddress { get; set; }
總結:
如果需要有判斷的,就用propfull
直接賦值使用的,就用prop
