Checking/unchecking check boxes in multiple rows at once

2 posts, 0 answers
  1. John
    John avatar
    16 posts
    Member since:
    Feb 2012

    Posted 22 Aug 2013 Link to this post

    I want the user to be able to do this:
    1. User selects multiple rows
    2. User clicks the check box in a check box column
    3. If the check box clicked was unchecked before clicking then change the check boxes to checked in all selected rows, else change the check boxes to unchecked in all selected rows

    The problem I am running into is that the selection seems to be cleared as soon as the check box is clicked.  Can you suggest a solution that would accomplish this behavior?

  2. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    3900 posts

    Posted 27 Aug 2013 Link to this post

    Hello John,

    Thank you for contacting Telerik Support.

    In order to obtain the desired scenario, please have a look at the following code snippet:
    public Form1()
        GridViewTextBoxColumn textBoxColumn = new GridViewTextBoxColumn("Product");
        GridViewCheckBoxColumn checkBoxColumn = new GridViewCheckBoxColumn("Discontinued");
        this.radGridView1.Rows.Add("Product1", true);
        this.radGridView1.Rows.Add("Product2", false);
        this.radGridView1.Rows.Add("Product3", false);
        this.radGridView1.Rows.Add("Product4", false);
        this.radGridView1.Rows.Add("Product5", true);
        this.radGridView1.Rows.Add("Product6", false);
        this.radGridView1.Rows.Add("Product7", true);
        this.radGridView1.Rows.Add("Product8", false);
        this.radGridView1.Rows.Add("Product9", true);
        this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
        this.radGridView1.MultiSelect = true;
        this.radGridView1.SelectionMode = GridViewSelectionMode.FullRowSelect;
        this.radGridView1.ValueChanging += radGridView1_ValueChanging;
    private void radGridView1_ValueChanging(object sender, ValueChangingEventArgs e)
        RadCheckBoxEditor editor = sender as RadCheckBoxEditor;
        if (editor != null)
            foreach (GridViewDataRowInfo row in this.radGridView1.SelectedRows)
                row.Cells[1].Value = e.NewValue;

    Have in mind that when clicking the check box, you should keep Ctrl key pressed in order not to loose selected rows.

    I hope this information helps. Should you have further questions, I would be glad to help.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top