上章遺留的 DefaultValueAttribute 問題已獲 Colin Han 解答:此特性協助 IDE 減少代碼生成。設計時屬性值等於預設值,IDE 不生成代碼;否則在 InitializeComponent 中生成賦值語句。
[Description("Customer's Age"), DefaultValue(20)]
public int Age { get; set; }
InitializeComponent 無 Age 賦值行this.customer1.Age = 40;本章原擬講 Component Designer,但讀者詢問自訂 Property Editor 如何偵錯。原用 MessageBox 輸出,lichdr 建議「附加至進程」偵錯,大幅改善體驗。
Components.Demo3.cs 設中斷點。
