我有一個文本框,我要綁定的DateTime屬性的對象:C#日期時間結合
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);
};
這完美的作品,當我改變文本框的值,屬性的變化。現在我想要反向(不解析文本)。
我想添加一個按鈕,增加1分鐘myObject.DateTimeProperty。問題是我不能做
myObject.DateTimeProperty.Minutes+=1;
也不
myObject.DateTimeProperty = myObject.DateTimeProperty.AddMinutes(1);
任何想法?
爲什麼你不能這樣做?有什麼問題? – 2009-12-03 13:06:57