views:

69

answers:

1

Hello,

I have a textbox I want to bind to DateTime property to an object :

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?

A: 

Does myobjoect implement INotifyPropertyChanged?

Sebastian Sedlak
Seems like he's not using WPF, but Windows Forms databinding.
Thorsten Dittmar
I'm pretty sure that the INotifyPropertyChanged interface works also with Windows Forms. Correct me if I'm wrong.
Sebastian Sedlak
Ok it works. I don't know what I have done, my bad :p
Toto