2014年11月23日 星期日

TextBox 如何對應 Nullable 資料欄??

最近專案使用到 TextBox 對應到 Nullable 的資料欄位,但如果發生編輯該欄位資料之後,又想改回空值時,卻發現游標卡住,無法跳到下一個欄位。

解決方案:

在 *.Designer.cs 中找到
DataBindings.Add(new System.Windows.Forms.Binding("Text", myClass, "MyTextProperty", true);

加入如下紅色字串部份,即可:
DataBindings.Add(new System.Windows.Forms.Binding("Text", myClass, "MyTextProperty", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged, string.Empty));

沒有留言:

張貼留言