Skip to content

Commit f02f57b

Browse files
authored
Merge pull request #4 from SyncfusionExamples/ES-10572
Add the image
2 parents afb9fff + dff8415 commit f02f57b

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

README.md

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
1-
# How to get a tree node in mouse double click event in WPF TreeGrid (SfTreeGrid)?
1+
# How to get a tree node in mouse double click event in WPF TreeGrid?
22

3-
## About the sample
4-
This example illustrates how to get a tree node in mouse double click event in WPF TreeGrid (SfTreeGrid)
3+
In [WPF TreeGrid](https://www.syncfusion.com/wpf-controls/treegrid) (SfTreeGrid), you can get the [TreeNode](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeNode.html) based on row and column index from the mouse pointer position. The [TreeNode](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeNode.html) can be accessed by using any mouse events (example MouseDoubleClick event). This event is triggered when you double click on the [TreeNode](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeNode.html). Within this event, you can access the [TreeGridPanel](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeGridPanel.html) by using the [GetTreePanel](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.Helpers.TreeGridHelper.html#Syncfusion_UI_Xaml_TreeGrid_Helpers_TreeGridHelper_GetTreePanel_Syncfusion_UI_Xaml_TreeGrid_SfTreeGrid_) extension method that exists in the [Syncfusion.UI.Xaml.TreeGrid.Helpers](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.Helpers.html).
54

6-
In [SfTreeGrid](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.SfTreeGrid.html), you can get the [TreeNode](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeNode.html) based on row and column index from the mouse pointer position. The [TreeNode](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeNode.html) can be accessed by using any mouse events (example MouseDoubleClick event). This event is triggered when you double click on the [TreeNode](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeNode.html). Within this event, you can access the [TreeGridPanel](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeGridPanel.html) by using the [GetTreePanel()](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.Helpers.TreeGridHelper.html#Syncfusion_UI_Xaml_TreeGrid_Helpers_TreeGridHelper_GetTreePanel_Syncfusion_UI_Xaml_TreeGrid_SfTreeGrid_) extension method that exists in the [Syncfusion.UI.Xaml.TreeGrid.Helpers](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.Helpers.html).
5+
The row index of [TreeNode](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeNode.html) in the clicked position can be retrieved by resolving the mouse click position through [TreeGridPanel.PointToCellRowColumnIndex](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeGridPanel.html#Syncfusion_UI_Xaml_TreeGrid_TreeGridPanel_PointToCellRowColumnIndex_System_Windows_Point_System_Boolean_). now, you can get the current [TreeNode](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeNode.html) by passing the **RowIndex** in [GetNodeAtRowIndex](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeGridIndexResolver.html#Syncfusion_UI_Xaml_TreeGrid_TreeGridIndexResolver_GetNodeAtRowIndex_Syncfusion_UI_Xaml_TreeGrid_SfTreeGrid_System_Int32_) method in TreeGrid.
76

8-
The row index of [TreeNode](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeNode.html) in the clicked position can be retrieved by resolving the mouse click position through [TreeGridPanel.PointToCellRowColumnIndex](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeGridPanel.html#Syncfusion_UI_Xaml_TreeGrid_TreeGridPanel_PointToCellRowColumnIndex_System_Windows_Point_System_Boolean_). now, you can get the current [TreeNode](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeNode.html) by passing the **RowIndex** in [GetNodeAtRowIndex](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeGridIndexResolver.html#Syncfusion_UI_Xaml_TreeGrid_TreeGridIndexResolver_GetNodeAtRowIndex_Syncfusion_UI_Xaml_TreeGrid_SfTreeGrid_System_Int32_) method in [SfTreeGrid](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.SfTreeGrid.html).
9-
10-
11-
```C#
7+
```Csharp
128

139
this.treeGrid.MouseDoubleClick += TreeGrid_MouseDoubleClick;
1410

1511
private void TreeGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1612
{
17-
var treeGridPanel = this.treeGrid.GetTreePanel();
18-
// get the row and column index based on the pointer position
19-
var rowColumnIndex = treeGridPanel.PointToCellRowColumnIndex(e.GetPosition(treeGridPanel));
20-
if (rowColumnIndex.IsEmpty)
21-
return;
22-
var treeNodeAtRowIndex = treeGrid.GetNodeAtRowIndex(rowColumnIndex.RowIndex);
23-
MessageBox.Show("TreeNode : " + treeNodeAtRowIndex.ToString());
13+
var treeGridPanel = this.treeGrid.GetTreePanel();
14+
// get the row and column index based on the pointer position
15+
var rowColumnIndex = treeGridPanel.PointToCellRowColumnIndex(e.GetPosition(treeGridPanel));
16+
if (rowColumnIndex.IsEmpty)
17+
return;
18+
var treeNodeAtRowIndex = treeGrid.GetNodeAtRowIndex(rowColumnIndex.RowIndex);
19+
MessageBox.Show("TreeNode : " + treeNodeAtRowIndex.ToString());
2420
}
2521

2622
```
2723

28-
![Shows the mouse double clicked TreeNode details in SfTreeGrid](GetTreeNodeViewMouseDoubleClick.gif)
29-
30-
KB article - [How to get a tree node in mouse double click event in WPF TreeGrid (SfTreeGrid)?](https://www.syncfusion.com/kb/12044/how-to-get-a-tree-node-in-mouse-double-click-event-in-wpf-treegrid-sftreegrid)
24+
![Shows the mouse double clicked TreeNode details in TreeGrid](GetTreeNodeViewMouseDoubleClick.gif)
3125

3226
## Requirements to run the demo
33-
Visual Studio 2015 and above versions
34-
35-
27+
Visual Studio 2015 and above versions

0 commit comments

Comments
 (0)