Problem Updatinh Databound TextBox when Underlying Property Changes

J

jehugaleahsa

Hello:

We have a class with a DateTime property and a string property that
represent that same date. We bind our text boxes to the string
property. We do this so that our users can enter dates in various
formats.

Inside the string property we verify the date format and conditionally
set the DateTime property.

Additionally, we have the getter of the string property format the
date.

The problem is that the unformatted text remains in the text box. We
are expecting the formatted string to appear after the user tabs away.
We have tried setting the type of binding to be OnPropertyChanged, but
this doesn't work.

We are not sure how to tell the interface to refresh. I also get the
feeling that we are not utilizing one of Windows Forms' built-in
features.

Please let me know if a string property is not the way to go. I would
much rather do things in a standard fashion. Any suggestions would be
appreciated.

Thanks,
Travis
 
B

Bjørn Brox

(e-mail address removed) skrev:
Hello:

We have a class with a DateTime property and a string property that
represent that same date. We bind our text boxes to the string
property. We do this so that our users can enter dates in various
formats.

Inside the string property we verify the date format and conditionally
set the DateTime property.

Additionally, we have the getter of the string property format the
date.

The problem is that the unformatted text remains in the text box. We
are expecting the formatted string to appear after the user tabs away.
We have tried setting the type of binding to be OnPropertyChanged, but
this doesn't work.

We are not sure how to tell the interface to refresh. I also get the
feeling that we are not utilizing one of Windows Forms' built-in
features.

Please let me know if a string property is not the way to go. I would
much rather do things in a standard fashion. Any suggestions would be
appreciated.

Isn't it better use a DateTimePicker instead of a TextBox to avoid all
kind of errors that a user can do by manually enter a date?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top