add line separator to grid based on checked rows

2 posts, 1 answers
  1. John
    John avatar
    60 posts
    Member since:
    Nov 2006

    Posted 04 Jul 2013 Link to this post

    I have a grid with a check box in it as the first column.  when users check stuff, i resort the grid to move all checked rows to the top of the grid to group them together.  Is it possible to add a line separator between the checked and unchecked rows?  see the attached screen shot and this will make more sense.

    Thanks!
  2. Answer
    Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 08 Jul 2013 Link to this post

    Hello John,

    Thank you for writing.

    To achieve the desired functionality, I would suggest that you use the CellFormatting event of the control, where you can compare the value of the check box cell for the current and the next row and if it differs, you can change the appearance of the bottom border to the cells in that row. Here is an example:
    void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
    {
        int index = radGridView1.ChildRows.IndexOf(e.Row);
        index++;
     
        GridViewRowInfo nextRow = null;
        if (radGridView1.ChildRows.Count > index)
        {
            nextRow = radGridView1.ChildRows[index];
        }
     
        if (nextRow != null && !object.Equals(e.Row.Cells["BoolColumn"].Value, nextRow.Cells["BoolColumn"].Value))
        {
            e.CellElement.BorderBottomColor = Color.Red;
            e.CellElement.BorderBottomWidth = 5;
        }
        else
        {
            e.CellElement.ResetValue(LightVisualElement.BorderBottomColorProperty, ValueResetFlags.Local);
            e.CellElement.ResetValue(LightVisualElement.BorderBottomWidthProperty, ValueResetFlags.Local);
        }
    }

    I hope that you find this information useful.

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top