G
Guest
Hi,
I've created a custom control derived from TextBox, which internally parses
the Text to a decimal value (in the OnValidated method) and exposes this
value as a Value property.
The control handles invalid input in an overwritten OnValidating method by
setting the Cancel member of the CancelEventArgs parameter to true (and by
changing the background color of the control).
I now want to bind the Value property of my control to some class property.
When I do so, i get two issues:
First, if I set the update mode to DataSourceUpdateMode.OnValidation and
enter a value in my text box, I have to leave the textbox twice using TAB key
(so I must press TAB, go back to the text box and press TAB again) before the
value is accepted. When the update mode is
DataSourceUpdateMode.OnPropertyChanged, overything goes fine.
Second, If I enter a wrong value into the text box, the focus still moves on
to the next control instead of staying in my text box, although the form's
AutoValidate property is set to EnablePreventFocusChange.
I would like my databound control to behave like the other (non-bound)
controls. Do you have any ideas what's happening? Does the databinding
mechanism influence/bypass the normal validation cycle in any way? Should I
use another method to parse the Text property (and set my new Value property)?
Thank you in advance
I've created a custom control derived from TextBox, which internally parses
the Text to a decimal value (in the OnValidated method) and exposes this
value as a Value property.
The control handles invalid input in an overwritten OnValidating method by
setting the Cancel member of the CancelEventArgs parameter to true (and by
changing the background color of the control).
I now want to bind the Value property of my control to some class property.
When I do so, i get two issues:
First, if I set the update mode to DataSourceUpdateMode.OnValidation and
enter a value in my text box, I have to leave the textbox twice using TAB key
(so I must press TAB, go back to the text box and press TAB again) before the
value is accepted. When the update mode is
DataSourceUpdateMode.OnPropertyChanged, overything goes fine.
Second, If I enter a wrong value into the text box, the focus still moves on
to the next control instead of staying in my text box, although the form's
AutoValidate property is set to EnablePreventFocusChange.
I would like my databound control to behave like the other (non-bound)
controls. Do you have any ideas what's happening? Does the databinding
mechanism influence/bypass the normal validation cycle in any way? Should I
use another method to parse the Text property (and set my new Value property)?
Thank you in advance