You must Sign In to post a response.
  • Category: .NET

    Uncheck All Check Box

    How can I uncheck all check box with single code on a windows form
    Example for Textbox I have written the following code

    Dim Ctr As Control
    For Each Ctr In Me.Controls
    If TypeOf Ctr Is TextBox Then
    Ctr.Text = String.Empty
    End If
    Next

    Mona
  • #499831
    When did you want Uncheck, When clicking another Check-box or simply by clicking Button?

    If button means,
    It is easy that we can code,
    checkbox1.unchecked=true;

    Thanks,
    Mani

  • #499836
    I have a button and 23 check boxes
    When I click on button All check boxes should be unchecked in single piece of code

  • #499837
    same as this


    Dim Ctr As Control
    For Each Ctr In Me.Controls
    If TypeOf Ctr Is CheckBox Then
    Ctr.Checked=false
    End If
    Next


    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #499843
    private void btnCheck_Click(object sender, EventArgs e)
    {
    foreach (Control control in Controls)
    {
    CheckBox chkBox = control as CheckBox;
    if (chkBox != null)
    {
    chkBox.Checked = true;
    }
    }

    }

    private void btnUncheck_Click(object sender, EventArgs e)
    {
    foreach (Control control in Controls)
    {
    CheckBox chkBox = control as CheckBox;
    if (chkBox != null)
    {
    chkBox.Checked = false;
    }
    }
    }

  • #499859
    Do same as you have done with textbox just change condition to checkbox.
    Visit my blog at:

  • #499923
    Dim Ctr As Control
    For Each Ctr In Me.Controls
    If TypeOf Ctr Is TextBox Then
    Ctr.Text = String.Empty
    End If
    Next

    and use it:

    foreach (Control control in Controls)
    {
    CheckBox chkBox = control as CheckBox;
    if (chkBox != null)
    {
    chkBox.Checked = false;
    }

    Regards,

    Naveen Kumar.M


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.