(Using WPF application)
This is the situation:
There are 3 user input fields. 1 for hours, 1 for minutes and 1 for seconds.
Behind it is a checkbox for “divide time by half” that does nothing more than devide the timespan created by the user input by half.
But when the checkbox gets checked, i first make a check in the code if the user had put in any numbers in the fields: hours/minutes/seconds.
If all are 0, a messagebox pops up telling the user he needs to put in something.
But at this point, i want to “cancel” the checking of the checkbox.
Should i use something as e.Cancel or something ?
Or should i set the IsChecked back to false together with the messagebox ?
Im wondering wat the correct way of dealing with this is.
I think your approach is wrong.
The checkbox should enable only when there is valid input.
You could set a LostFocus event on your textboxes and inside that event check the all the input values.
If input is right then enable the checkbox else disable it. No need to cancel the checkmark