Getting Started with Windows Forms ComboBox DropDown (ComboDropDown)

6 Oct 20223 minutes to read

In this section, ComboDropDown is used to host TreeView control and this can be achieved in the following ways.

Through Designer

This section will guide you to create a ComboDropDown control through designer and associate a TreeView control as its popup.

The below steps will guide you with this.

  1. Create a new Visual C# application or VB.NET application in Visual Studio .NET.

    Create new application

  2. Drag and drop a ComboDropDown control, TreeView control from the toolbox onto the form.

    Drag and drop ComboDropDown control

  3. Add nodes to the TreeView control and set HideSelection property to false. The HideSelection property specifies whether the selected tree node remains highlighted even when the tree view has lost the focus.

    set HideSelection property to false

  4. Now set the ComboDropDown’s PopupControl property to be the above TreeView instance.

    set the ComboDropDowns PopupControl property

NOTE

We can also include code to set up the interaction between the combo and the treeview control. Refer_ Setting Interaction between ComboDropDown and TreeView.

Through Code

Drag and drop the TreeView control which will be used in the drop-down portion of ComboDropDown control.

  1. Include the required namespace.

    using Syncfusion.Windows.Forms.Tools;
    Imports Syncfusion.Windows.Forms.Tools
  2. Create an instance of the ComboDropDown control class.

    private Syncfusion.Windows.Forms.Tools.ComboDropDown comboDropDown1;
    this.comboDropDown1=new Syncfusion.Windows.Forms.Tools.ComboDropDown();
    Private comboDropDown1 As Syncfusion.Windows.Forms.Tools.ComboDropDown
    Me.comboDropDown1 = New Syncfusion.Windows.Forms.Tools.ComboDropDown()
  3. Add TreeView in the drop-down portion of ComboDropDown. Finally add ComboDropDown to the Form.

    this.comboDropDown1.PopupControl=this.treeView1;
    this.Controls.Add(this.comboDropDown1);
    Me.comboDropDown1.PopupControl=Me.treeView1
    Me.Controls.Add(Me.comboDropDown1)

NOTE

Refer Setting Interaction between ComboDropDown and TreeView to set the interaction between the ComboDropDown and Treeview.