HOW TO KNOW STATUS OF CHECK BOX IS CHECKED OR UNCHECKED

Anupam Mishra

Total Post:135

Points:949
Posted by  Anupam Mishra
C#  .NET 
C#
 374  View(s)
Ratings:
Rate this:
I want to use check box  and it will working on button click event , how to know check box is checked or unchecked(status) .After knowing status , i want to do some task.
thank you.
  1. Anupam Mishra

    Post:135

    Points:949
    Re: How to Know status of Check Box is checked or unchecked

    Here, we are using a groupBox container that add checkbox controls in a form. Code is same as below:

            CheckBox check = new CheckBox();
         check.AutoSize = false;
            check.Text = "This is check box";
                        check.AutoSize = true;
                        check.Location = new Point(50, 50);
                        groupBox1.Controls.Add(check);

    Here, we are code for checking checkbox status ,it is checked or unchecked :
            if ((check).Checked)
                         {
                          MessageBox.Show("checkbox is checked", "Test", MessageBoxButtons.OK, MessageBoxIcon.Question);
                        // Here you can code as you wish
                    }

    or we also checked a status of check box by using check.CheckStatus property.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!