C# datetime binding
I have a textbox I want to bind to DateTime property to an object :
开发者_JS百科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);
};
This works perfectly, when I change the textbox value, the property change. Now I want the reverse (without parsing the text).
I want to add a button that increment by 1 minutes myObject.DateTimeProperty. The issue is I can't do
myObject.DateTimeProperty.Minutes+=1;
nor
myObject.DateTimeProperty = myObject.DateTimeProperty.AddMinutes(1);
Any ideas?
Does myobjoect implement INotifyPropertyChanged?
精彩评论