-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #624 from telerik/new-kb-gridview-indent-selectcol…
…umn-group-winforms-73be8475721340ca9ff7047634a757e0 Added new kb article gridview-indent-selectcolumn-group-winforms
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
knowledge-base/gridview-indent-selectcolumn-group-winforms.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
title: How to Indent Select Column Checkbox for Grouped Rows | ||
description: Learn how to indent the Select Column Checkbox for group rows within RadGridView to enhance visual hierarchy. | ||
type: how-to | ||
page_title: How to Indent Select Column Checkbox for Grouped Rows in RadGridView for WinForms | ||
slug: gridview-indent-selectcolumn-group-winforms | ||
tags: gridview, ui, gridviewselectcolumn, indentation, child rows, grouping | ||
res_type: kb | ||
ticketid: 1661637 | ||
--- | ||
|
||
## Environment | ||
|
||
|Product Version|Product|Author| | ||
|----|----|----| | ||
|2024.3.806|RadGridView for WinForms|[Dinko Krastev](https://www.telerik.com/blogs/author/dinko-krastev)| | ||
|
||
## Description | ||
|
||
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. | ||
|
||
![WinForms RadGridView Select Column Indent](images/gridview-indent-selectcolumn-group-winforms001.png) | ||
|
||
## Solution | ||
|
||
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: | ||
|
||
1. Increase the size of the select column by setting the `SelectColumnWidth` property to a larger value, for example, 50: | ||
|
||
````C# | ||
this.radGridView1.TableElement.SelectColumnWidth = 50; | ||
|
||
```` | ||
|
||
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. | ||
|
||
````C# | ||
private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) | ||
{ | ||
if (e.CellElement is GridGroupRowSelectCellElement selectGroupCellElement ) | ||
{ | ||
selectGroupCellElement.CheckBoxElement.CheckAlignment = ContentAlignment.MiddleLeft; | ||
selectGroupCellElement.CheckBoxElement.Margin = new Padding(5,0,0,0); | ||
} | ||
} | ||
|
||
```` | ||
|
||
## See Also | ||
|
||
- [RadGridView for WinForms Documentation]({%slug winforms/gridview%}) | ||
- [GridViewSelectColumn]({%slug winforms/gridview/columns/column-types/gridviewselectcolumn%}) |
Binary file added
BIN
+15.3 KB
knowledge-base/images/gridview-indent-selectcolumn-group-winforms001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.