From f8c6028e3db73d8148fbcd846267b14939ff07d9 Mon Sep 17 00:00:00 2001 From: Sreemon Premkumar M Date: Mon, 18 Aug 2025 17:25:45 +0530 Subject: [PATCH 1/3] ES-975464 - Resolve the ReadMe file length issue in this sample repository --- README.md | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c31e5fe..f84b3a8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,40 @@ # How to search and select the record in wpf and uwp treegrid? -This example illustrates how to search and select the record in wpf and uwp treegrid + +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). + +You can search and select a record in `TreeGrid` based on the searched text using the `TextChanged` event of `TextBox`. + +``` c# +private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) +{ + var textBox = sender as TextBox; + var treeGrid = this.AssociatedObject.treeGrid; + if (textBox.Text == "") + treeGrid.SelectedItems.Clear(); + + for (int i = 0; i < treeGrid.View.Nodes.Count; i++) + { + if (Provider == null) + Provider = treeGrid.View.GetPropertyAccessProvider(); + + if (treeGrid.View.Nodes[i].HasChildNodes && treeGrid.View.Nodes[i].ChildNodes.Count == 0) + { + treeGrid.BeginInit(); + treeGrid.ExpandNode(treeGrid.View.Nodes[i]); + treeGrid.CollapseNode(treeGrid.View.Nodes[i]); + treeGrid.EndInit(); + } + else if (treeGrid.View.Nodes[i].HasChildNodes) + { + dataRow = (treeGrid.View.Nodes[i].Item as EmployeeInfo); + FindMatchText(dataRow); + GetChildNodes(treeGrid.View.Nodes[i]); + } + else + { + dataRow=(treeGrid.View.Nodes[i].Item as EmployeeInfo); + FindMatchText(dataRow); + } + } +} +``` From b5b8508779c01aa1d01cfc8cc3c26d8b2d57efcd Mon Sep 17 00:00:00 2001 From: SreemonPremkumarM Date: Fri, 31 Oct 2025 00:45:19 +0530 Subject: [PATCH 2/3] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f84b3a8..8b5cecf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# How to search and select the record in wpf and uwp treegrid? +# How to Search and Select the Record in WPF and UWP TreeGrid? -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). +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). You can search and select a record in `TreeGrid` based on the searched text using the `TextChanged` event of `TextBox`. From e2b1282ef516881dc382a0e1e286de75a8ce4c05 Mon Sep 17 00:00:00 2001 From: SreemonPremkumarMuthukrishnan Date: Fri, 31 Oct 2025 00:49:51 +0530 Subject: [PATCH 3/3] ES-975464 - Addressed the concern --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8b5cecf..45d2d23 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,11 @@ 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). -You can search and select a record in `TreeGrid` based on the searched text using the `TextChanged` event of `TextBox`. +## For WPF: -``` c# +You can search and select a record in TreeGrid based on the searched text using the TextChanged event of TextBox. + +``` csharp private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { var textBox = sender as TextBox; @@ -38,3 +40,40 @@ private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChan } } ``` + +## For UWP: + +You can search and select a record in TreeGrid based on the searched text using the TextChanged event of TextBox. + +``` csharp +private void Textbox_TextChanged(object sender, TextChangedEventArgs e) +{ + var textBox = sender as TextBox; + + if (textBox.Text == "") + treeGrid.SelectedItems.Clear(); + + for (int i = 0; i < treeGrid.View.Nodes.Count; i++) + { + if (Provider == null) + Provider = treeGrid.View.GetPropertyAccessProvider(); + + if (treeGrid.View.Nodes[i].HasChildNodes && treeGrid.View.Nodes[i].ChildNodes.Count == 0) + { + treeGrid.ExpandNode(treeGrid.View.Nodes[i]); + treeGrid.CollapseNode(treeGrid.View.Nodes[i]); + } + else if (treeGrid.View.Nodes[i].HasChildNodes) + { + dataRow = (treeGrid.View.Nodes[i].Item as PersonInfo); + FindMatchText(dataRow); + GetChildNodes(treeGrid.View.Nodes[i]); + } + else + { + dataRow = (treeGrid.View.Nodes[i].Item as PersonInfo); + FindMatchText(dataRow); + } + } +} +``` \ No newline at end of file