We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to display TreeView as the dropdown of the ComboBox in XPMenus in the WinForms XPToolBar?

Platform: WinForms |
Control: XPToolbar

Display TreeView as the dropdown of the ComboBox inXPMenus

The XP Menus framework provides the flexibility to add detached toolbars through CommandBar that can host any .NET control. So, to achieve this we can add the Treeview control as the PopupControl of the ComboBoxDropDown and it can be added to the CommandBar of the XPMenus.


private TreeNode FindNode(TreeNodeCollection nodes, string text)
   foreach (TreeNode child in nodes)
      if (child.Text == text)
         return child;
   foreach (TreeNode child in nodes)
      TreeNode matched = this.FindNode(child.Nodes, text);
      if (matched != null)
         return matched;
return null;
private void comboDropDown1_DropDown(object sender, EventArgs e)
   // Before the drop-down is shown, select a TreeNode based on the text in the combo.
   if (this.comboDropDown1.Text != String.Empty)
      TreeNode matchedNode = this.FindNode(this.treeView1.Nodes, this.comboDropDown1.Text);
      this.treeView1.SelectedNode = matchedNode;


Private Function FindNode(ByVal nodes As TreeNodeCollection, ByVal text As String) As TreeNode
   For Each child As TreeNode In nodes
       If child.Text = text Then
          Return child
       End If
   Next child
   For Each child As TreeNode In nodes
       Dim matched As TreeNode = Me.FindNode(child.Nodes, text)
       If matched IsNot Nothing Then
          Return matched
       End If
   Next child
   Return Nothing
End Function
Private Sub comboDropDown1_DropDown(ByVal sender As Object, ByVal e As EventArgs) Handles comboDropDown1.DropDown
   '' Before the drop-down is shown, select a TreeNode based on the text in the combo.
   If Me.comboDropDown1.Text <> String.Empty Then
      Dim matchedNode As TreeNode = Me.FindNode(Me.treeView1.Nodes, Me.comboDropDown1.Text)
      Me.treeView1.SelectedNode = matchedNode
   End If
End Sub


2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment
Ayman Metwally
Feb 11, 2019

Can you please reshare the link of this sample?


Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile