Skip to content

Commit 102b249

Browse files
author
KB Bot
committed
Added new kb article how-to-access-selected-hierarchy-row-radgridview-winforms
1 parent 05f27bd commit 102b249

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: How to get selected rows in the Child Grid of RadGridView for WinForms
3+
description: Learn how to programmatically determine and access the selected row in a child grid within RadGridView for WinForms.
4+
type: how-to
5+
page_title: How to get the selected Selected Child Rows in RadGridView for WinForms
6+
slug: how-to-access-selected-hierarchy-row-radgridview-winforms
7+
tags: gridview, winforms, child grid, selected row, hierarchy
8+
res_type: kb
9+
ticketid: 1673149
10+
---
11+
12+
## Environment
13+
14+
|Product Version|Product|Author|
15+
|----|----|----|
16+
|2024.4.1113|RadSpreadsheet for WinForms|[Dinko Krastev](https://www.telerik.com/blogs/author/dinko-krastev)|
17+
18+
## Description
19+
20+
When working with hierarchical RadGridView for WinForms, it's essential to identify the selected rows within the child grids programmatically. In the following KB article, we will demonstrate how to determine whether the rows in the SelectedRows collection are from the master or child template.
21+
22+
## Solution
23+
24+
To access selected rows within a child grid of RadGridView, leverage the `RadGridView.SelectedRows` collection. This collection holds all selected rows when the `SelectionMode` is set to `GridViewSelectionMode.FullRowSelect`.
25+
26+
To specifically target selected rows in child grids, iterate over the `SelectedRows` collection and utilize the `HierarchyLevel` property of each row to determine its hierarchical level. The following code snippet demonstrates how to identify and work with selected rows at the child level (`HierarchyLevel == 1`):
27+
28+
````C#
29+
30+
foreach (GridViewRowInfo row in this.radGridView.SelectedRows)
31+
{
32+
if (row.HierarchyLevel == 1)
33+
{
34+
// Implement the desired logic for selected child rows here
35+
}
36+
}
37+
38+
````
39+
40+
This approach enables you to distinguish between selected rows in the main grid and those in child grids, facilitating precise manipulation or processing based on your application's requirements.
41+
42+
## See Also
43+
44+
- [RadGridView for WinForms Documentation - Selection](https://docs.telerik.com/devtools/winforms/controls/gridview/selection/selection-basics)
45+
- [RadGridView for WinForms Documentation - Hierarchical Grid](https://docs.telerik.com/devtools/winforms/controls/gridview/hierarchical-grid/hierarchical-grid)

0 commit comments

Comments
 (0)