开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜