Skip to content

SyncfusionExamples/how-to-search-and-select-the-record-in-wpf-and-uwp-treegrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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 and UWP TreeGrid (SfTreeGrid).

For WPF:

You can search and select a record in TreeGrid based on the searched text using the TextChanged event of TextBox.

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); } } }

For UWP:

You can search and select a record in TreeGrid based on the searched text using the TextChanged event of TextBox.

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); } } }

About

This example illustrates how to search and select the record in wpf and uwp treegrid

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages