I’m using C#, how do I check if a checkbox is checked on a form from a class file?
It’s a winform app.
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.
This sounds like you are going down the road of tight coupling and that’s something you should avoid. Your worker class should not directly talk to objects on the form.
You can send the
Checkedvalue to the worker class when you initialize it or as a method parameter if you are calling it from the form.If you are sending the form to the worker class, you should provide a public property on the form that returns the appropriate state of the CheckBox and access that property in your worker class.
You can also make your CheckBox itself public or internal on the form by changing the Modifiers value in the Designer. I don’t recommend this though.