Skip to content

Commit 83c23ea

Browse files
authored
Merge pull request #624 from telerik/new-kb-gridview-indent-selectcolumn-group-winforms-73be8475721340ca9ff7047634a757e0
Added new kb article gridview-indent-selectcolumn-group-winforms
2 parents cdbc852 + 10ff85d commit 83c23ea

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
![WinForms RadGridView Select Column Indent](images/gridview-indent-selectcolumn-group-winforms001.png)
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%})
Loading

0 commit comments

Comments
 (0)