|
| 1 | +--- |
| 2 | +title: How to Indent Select Column Checkbox for Grouped Rows |
| 3 | +description: Learn how to indent the Select Column Checkbox for group rows within RadGridView to enhance visual hierarchy. |
| 4 | +type: how-to |
| 5 | +page_title: How to Indent Select Column Checkbox for Grouped Rows in RadGridView for WinForms |
| 6 | +slug: gridview-indent-selectcolumn-group-winforms |
| 7 | +tags: gridview, ui, gridviewselectcolumn, indentation, child rows, grouping |
| 8 | +res_type: kb |
| 9 | +ticketid: 1661637 |
| 10 | +--- |
| 11 | + |
| 12 | +## Environment |
| 13 | + |
| 14 | +|Product Version|Product|Author| |
| 15 | +|----|----|----| |
| 16 | +|2024.3.806|RadGridView for WinForms|[Dinko Krastev](https://www.telerik.com/blogs/author/dinko-krastev)| |
| 17 | + |
| 18 | +## Description |
| 19 | + |
| 20 | +When using the `GridViewSelectColumn` in a grouped scenario within RadGridView for WinForms, it might be beneficial to visually distinguish group rows from child rows. One way to achieve this is by indenting the Select Column Checkbox inside the parent group rows. This article demonstrates how to simulate checkbox indentation for a clearer visual hierarchy. |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +## Solution |
| 25 | + |
| 26 | +To achieve the indentation effect for the Select Checkbox of child rows, you can adjust the `SelectColumnWidth` property and modify the `CheckBoxElement` alignment and margin in the `GridGroupRowSelectCellElement` through the `ViewCellFormatting` event. Follow these steps: |
| 27 | + |
| 28 | +1. Increase the size of the select column by setting the `SelectColumnWidth` property to a larger value, for example, 50: |
| 29 | + |
| 30 | +````C# |
| 31 | +this.radGridView1.TableElement.SelectColumnWidth = 50; |
| 32 | + |
| 33 | +```` |
| 34 | + |
| 35 | +2. Subscribe to the `ViewCellFormatting` event of RadGridView. Within the `ViewCellFormatting` event handler, adjust the `CheckBoxElement` in the `GridGroupRowSelectCellElement` to align it to the left and add a left margin. This simulates an indentation effect for group row checkboxes, leaving the child items' checkbox select cell position unchanged. |
| 36 | + |
| 37 | +````C# |
| 38 | +private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) |
| 39 | +{ |
| 40 | + if (e.CellElement is GridGroupRowSelectCellElement selectGroupCellElement ) |
| 41 | + { |
| 42 | + selectGroupCellElement.CheckBoxElement.CheckAlignment = ContentAlignment.MiddleLeft; |
| 43 | + selectGroupCellElement.CheckBoxElement.Margin = new Padding(5,0,0,0); |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +```` |
| 48 | + |
| 49 | +## See Also |
| 50 | + |
| 51 | +- [RadGridView for WinForms Documentation]({%slug winforms/gridview%}) |
| 52 | +- [GridViewSelectColumn]({%slug winforms/gridview/columns/column-types/gridviewselectcolumn%}) |
0 commit comments