Skip to content

Commit

Permalink
Merge pull request #624 from telerik/new-kb-gridview-indent-selectcol…
Browse files Browse the repository at this point in the history
…umn-group-winforms-73be8475721340ca9ff7047634a757e0

Added new kb article gridview-indent-selectcolumn-group-winforms
  • Loading branch information
nade7o authored Sep 17, 2024
2 parents cdbc852 + 10ff85d commit 83c23ea
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions knowledge-base/gridview-indent-selectcolumn-group-winforms.md
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%})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 83c23ea

Please sign in to comment.