[英]C# datetime binding
我有一個文本框,我想將DateTime屬性綁定到一個對象:
myTextBox.DataBindings.Add("Text",myObject,"DateTimeProperty")
myTextBox.DataBindings["Text"].FormatString = "HH:mm";
myTextBox.DataBindings["Text"].FormattingEnabled = true;
myTextBox.DataBindings["Text"].BindingComplete +=
delegate(object sender, BindingCompleteEventArgs e)
{
if (e.Exception is FormatException)
MessageBox.Show("Wrong formating, should be :" +myTextBox.DataBindings["Text"].FormatString);
};
當我更改文本框的值時,屬性會發生變化,這非常完美。 現在我要相反(不解析文本)。
我想添加一個按鈕,使myObject.DateTimeProperty增加1分鍾。 問題是我做不到
myObject.DateTimeProperty.Minutes+=1;
也不
myObject.DateTimeProperty = myObject.DateTimeProperty.AddMinutes(1);
有任何想法嗎?
myobjoect是否實現INotifyPropertyChanged嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.