Skip to content

Commit e2b1282

Browse files
ES-975464 - Addressed the concern
1 parent b5b8508 commit e2b1282

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
This example illustrates how to search and select the record in [WPF TreeGrid](https://www.syncfusion.com/wpf-controls/treegrid) and [UWP TreeGrid](https://www.syncfusion.com/uwp-ui-controls/treegrid) (SfTreeGrid).
44

5-
You can search and select a record in `TreeGrid` based on the searched text using the `TextChanged` event of `TextBox`.
5+
## For WPF:
66

7-
``` c#
7+
You can search and select a record in TreeGrid based on the searched text using the TextChanged event of TextBox.
8+
9+
``` csharp
810
private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
911
{
1012
var textBox = sender as TextBox;
@@ -38,3 +40,40 @@ private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChan
3840
}
3941
}
4042
```
43+
44+
## For UWP:
45+
46+
You can search and select a record in TreeGrid based on the searched text using the TextChanged event of TextBox.
47+
48+
``` csharp
49+
private void Textbox_TextChanged(object sender, TextChangedEventArgs e)
50+
{
51+
var textBox = sender as TextBox;
52+
53+
if (textBox.Text == "")
54+
treeGrid.SelectedItems.Clear();
55+
56+
for (int i = 0; i < treeGrid.View.Nodes.Count; i++)
57+
{
58+
if (Provider == null)
59+
Provider = treeGrid.View.GetPropertyAccessProvider();
60+
61+
if (treeGrid.View.Nodes[i].HasChildNodes && treeGrid.View.Nodes[i].ChildNodes.Count == 0)
62+
{
63+
treeGrid.ExpandNode(treeGrid.View.Nodes[i]);
64+
treeGrid.CollapseNode(treeGrid.View.Nodes[i]);
65+
}
66+
else if (treeGrid.View.Nodes[i].HasChildNodes)
67+
{
68+
dataRow = (treeGrid.View.Nodes[i].Item as PersonInfo);
69+
FindMatchText(dataRow);
70+
GetChildNodes(treeGrid.View.Nodes[i]);
71+
}
72+
else
73+
{
74+
dataRow = (treeGrid.View.Nodes[i].Item as PersonInfo);
75+
FindMatchText(dataRow);
76+
}
77+
}
78+
}
79+
```

0 commit comments

Comments
 (0)