I mean, I’ve got a checkbox, and when it click on it.. I need to run a function to verify if can change IsChecked value or not.
It seems like a validation.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
Checked(UnChecked/CheckedChanged) event(s) of the checkbox (depending on if its a WPF or a WinForms application):If the new checked state is not valid, it (un)checks the checkbox again and puts it in a valid state.
Another (and better) approach would be to disable the checkbox if a certain condition is not met (like a state of another control). It is confusing for the user if he or she checks a box and it’s state is not changing without any feedback.
See MSDN for WPF / MSDN for WinForms for further informations.