SelectAll method giving error in HeaderCellToggleStateChanged

2 posts, 0 answers
  1. Lokesh
    Lokesh avatar
    7 posts
    Member since:
    Jan 2012

    Posted 14 May 2015 Link to this post

    I am using a Q1 2015 Winforms RadGrid, added a checkbox column, made EnabledHeaderCheckbox = true, added following event and now want to select all rows in the grid when header checkbox is checked, but it is giving object reference error. Here is the code examples - 


            private void _sampleRadGridView_HeaderCellToggleStateChanged(object sender, GridViewHeaderCellEventArgs e)
                if (e.State.ToString() == "On")


    Please help. Thanks

  2. Dess
    Dess avatar
    2174 posts

    Posted 18 May 2015 Link to this post

    Hello Lokesh,

    Thank you for writing.

    I confirm that it is an issue with RadGridView. I have logged it in our feedback portal. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - feedback item.

    I have also updated your Telerik points.

    Currently, the possible solution that I can suggest is to select manually each row without Begin/EndUpdate block which will refresh the whole grid:
    private void radGridView1_HeaderCellToggleStateChanged(object sender, GridViewHeaderCellEventArgs e)
        bool selected = e.State.ToString() == "On";
        foreach (GridViewRowInfo r in this.radGridView1.Rows)
            r.IsSelected = selected;

    An alternative solution is to use the MouseUp event:
    private void radGridView1_MouseUp(object sender, MouseEventArgs e)
        RadCheckBoxElement el = this.radGridView1.ElementTree.GetElementAtPoint(e.Location) as RadCheckBoxElement;
        if (el!=null)
            GridCheckBoxHeaderCellElement headerCell = el.Parent as GridCheckBoxHeaderCellElement;
            bool selected = el.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On;
            if (headerCell!=null)
                if (selected)

    I hope this information helps. Should you have further questions, I would be glad to help.
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top