diff --git a/README.md b/README.md index d97bd4b..33cb835 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # How to search and retrieve the tree node based on its text in WinForms TreeViewAdv? -## Search and retrieve the TreeNodeAdv text +In [WinForms TreeViewAdv](https://www.syncfusion.com/winforms-ui-controls/treeview) has built-in support to search the **TreeNodeAdv** based on its text, by using the class named **TreeViewAdvFindReplaceDialog**. It can be done using the following categories: -**TreeViewAdv** has built-in support to search the **TreeNodeAdv** based on its text, by using the class named **TreeViewAdvFindReplaceDialog**. It can be done using the following categories: 1. TreeViewSearchOption 2. TreeViewSearchRange 3. TreeViewSearchNavigation ## TreeViewSearchOption This property specifies the Searching option in TreeViewAdv. + 1. MatchWholeText 2. MatchCase @@ -78,13 +78,14 @@ This option helps to specify whether the search needs to be performed from the t This option helps to specify whether the search can be performed in the above cases repeatedly. The following code example demonstrates the same. -**C# Code snippet:** +**C#:** ```C# //Initialize the TreeViewSearchForm TreeViewSearchForm form; //To assign the TreeViewAdv to TreeViewSearchForm form = new TreeViewSearchForm(this.treeViewAdv1); + //To show the search dialog void treeViewAdv1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { @@ -101,7 +102,8 @@ public partial class TreeViewSearchForm : MetroForm TreeViewAdvFindReplaceDialog dialog = null; //Initialize the TreeViewAdv private TreeViewAdv TreeView; - //To pass the TreeviewAdv argument to the form. + + //To pass the TreeviewAdv argument to the form. public TreeViewSearchForm(TreeViewAdv tree) { InitializeComponent(); @@ -109,31 +111,37 @@ public partial class TreeViewSearchForm : MetroForm //To assign the TreeViewAdv to TreeViewSearchForm dialog = new TreeViewAdvFindReplaceDialog(this.TreeView); } + //To get the TreeViewSearchNavigation void comboBox3_SelectedIndexChanged(object sender, EventArgs e) { dialog.TreeViewSearchNavigation = (TreeViewSearchNavigation)this.SearchRangeCombo.Items[this.comboBox3.Items.IndexOf(this.comboBox3.SelectedItem)]; } + //To get the TreeViewSearchRange private void SearchRangeCombo_SelectedIndexChanged(object sender, EventArgs e) { dialog.TreeViewSearchRange = (TreeViewSearchRange)this.SearchRangeCombo.Items[this.SearchRangeCombo.Items.IndexOf(this.SearchRangeCombo.SelectedItem)]; } + //To get the TreeViewSearchOption private void SearchOptionCombo_SelectedIndexChanged(object sender, EventArgs e) { dialog.TreeViewSearchOption = (TreeViewSearchOption)this.SearchOptionCombo.Items[this.SearchOptionCombo.Items.IndexOf(this.SearchOptionCombo.SelectedItem)]; } + //To Find TreeNodeAdv private void button1_Click(object sender, EventArgs e) { dialog.Find(this.findTextBox.Text); } + //To Find All the TreeNodeAdv private void button2_Click(object sender, EventArgs e) { dialog.FindAll(this.findTextBox.Text); } + //To Replace the TreeNodeAdv private void button3_Click(object sender, EventArgs e) { @@ -141,6 +149,7 @@ public partial class TreeViewSearchForm : MetroForm if(dialog.Find(this.findTextBox.Text)) dialog.Replace(this.replaceTextbox.Text); } + //To Replace All the TreeNodeAdv private void button4_Click(object sender, EventArgs e) { @@ -152,7 +161,7 @@ public partial class TreeViewSearchForm : MetroForm ``` -**VB Code snippet:** +**VB.Net:** ```VB @@ -160,6 +169,7 @@ public partial class TreeViewSearchForm : MetroForm Private form As TreeViewSearchForm 'To assign the TreeViewAdv to TreeViewSearchForm form = New TreeViewSearchForm(Me.treeViewAdv1) + 'To show the search dialog Private Sub treeViewAdv1_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) If e.Modifiers = Keys.Control AndAlso e.KeyValue = Keys.F Then @@ -174,6 +184,7 @@ Partial Public Class TreeViewSearchForm Private dialog As TreeViewAdvFindReplaceDialog = Nothing 'Initialize the TreeViewAdv Private TreeView As TreeViewAdv + 'To pass the TreeviewAdv argument to the form. Public Sub New(ByVal tree As TreeViewAdv) InitializeComponent() @@ -181,26 +192,32 @@ Partial Public Class TreeViewSearchForm 'To assign the TreeViewAdv to TreeViewSearchForm dialog = New TreeViewAdvFindReplaceDialog(Me.TreeView) End Sub + 'To get the TreeViewSearchNavigation Private Sub comboBox3_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) dialog.TreeViewSearchNavigation = CType(Me.SearchRangeCombo.Items(Me.comboBox3.Items.IndexOf(Me.comboBox3.SelectedItem)), TreeViewSearchNavigation) End Sub + 'To get the TreeViewSearchRange Private Sub SearchRangeCombo_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles SearchRangeCombo.SelectedIndexChanged dialog.TreeViewSearchRange = CType(Me.SearchRangeCombo.Items(Me.SearchRangeCombo.Items.IndexOf(Me.SearchRangeCombo.SelectedItem)), TreeViewSearchRange) End Sub + 'To get the TreeViewSearchOption Private Sub SearchOptionCombo_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles SearchOptionCombo.SelectedIndexChanged dialog.TreeViewSearchOption = CType(Me.SearchOptionCombo.Items(Me.SearchOptionCombo.Items.IndexOf(Me.SearchOptionCombo.SelectedItem)), TreeViewSearchOption) End Sub + 'To Find TreeNodeAdv Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click dialog.Find(Me.findTextBox.Text) End Sub + 'To Find All the TreeNodeAdv Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button2.Click dialog.FindAll(Me.findTextBox.Text) End Sub + 'To Replace the TreeNodeAdv Private Sub button3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button3.Click Me.TreeView.SelectedNodes.Clear() @@ -208,6 +225,7 @@ Partial Public Class TreeViewSearchForm dialog.Replace(Me.replaceTextbox.Text) End If End Sub + 'To Replace All the TreeNodeAdv Private Sub button4_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button4.Click Me.TreeView.SelectedNodes.Clear()