Header Checkbox Won't Update

2 posts, 0 answers
  1. Ryan
    Ryan avatar
    35 posts
    Member since:
    Jul 2015

    Posted 30 Apr Link to this post

    Hello,

    I was unchecking a cell programmatically and was expecting the same behavior as when I uncheck it through the UI, but it seems that the header checkbox is not updated when you modify a cell's value programmatically:

    private void RadForm1_Load(object sender, EventArgs e)
    {
        radGridView1.AllowSearchRow = true;
        radGridView1.TableElement.SearchHighlightColor = Color.Orange;
        radGridView1.AutoExpandGroups = true;
     
        DataTable dt = new DataTable();
     
        dt.Columns.Add("test", typeof(bool));
     
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
        dt.Rows.Add(true);
     
        radGridView1.DataSource = dt;
     
        ((Telerik.WinControls.UI.GridViewCheckBoxColumn)radGridView1.Columns[0]).EnableHeaderCheckBox = true;
        ((Telerik.WinControls.UI.GridViewCheckBoxColumn)radGridView1.Columns[0]).Width = radGridView1.Width - 50;
     
        radGridView1.TableElement.Update(Telerik.WinControls.UI.GridUINotifyAction.Reset); //force header checkbox to check
     
        radGridView1.TableElement.ScrollTo(15, 0);
    }
     
    private void radButton1_Click(object sender, EventArgs e)
    {
        radGridView1.Rows[0].Cells[0].Value = false;
    }

    I have tried adding radGridView1.TableElement.BeginUpdate() to the beginning & radGridView1.TableElement.EndUpdate() to the end of radButton1_Click, along with radGridView1.TableElement.Update(Telerik.WinControls.UI.GridUINotifyAction.ExpandedChanged) & radGridView1.TableElement.Update(Telerik.WinControls.UI.GridUINotifyAction.Reset) immediately after changing the cell's value, but all of these lines seem to invalidate the RadGridView in one way or another. They cause the search row's buttons to flicker and scroll the RadGridView up to the top.

    Is there a solution to this problem that will result in behavior similar to checking/unchecking a cell using the UI?

    Thank you!

  2. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 02 May Link to this post

    Hi Ryan,

    Thank you for writing.

    I was able to reprduce the observed issue. I have logged it in our Feedback Portal. You can track the item for status changes and add your vote for it here.

    To workaround this you can manually update the cell with the line of code that you are alredy using:
    private void radButton1_Click(object sender, EventArgs e)
    {
        radGridView1.Rows[0].Cells[0].Value = false;
        radGridView1.TableElement.Update(Telerik.WinControls.UI.GridUINotifyAction.Reset);
    }

    Your Telerik Points have been updated for this report.

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top