Put TreeView in a ComboBox in win forms?

3 posts, 0 answers
  1. Joel Kraft
    Joel Kraft avatar
    87 posts
    Member since:
    Jan 2004

    Posted 30 Jan 2009 Link to this post

    I was wondering if it's possible to use a TreeView as the drop-down of a combo box in win forms like you can in ASP.NET?
  2. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 02 Feb 2009 Link to this post

    Hello Joel,

    Thanks for your question.

    It is possible to create a custom control which shows a custom pop up window. Take a look at the following code snippet:

    RadTreeView treeView = new RadTreeView(); 
    RadTreeNode treeNode = new RadTreeNode("Node 1"); 
    RadTreeNode childNode = new RadTreeNode("Child of 1"); 
    RadTreeNode childNode2 = new RadTreeNode("Child 2 of 1"); 
     
    treeNode.Nodes.Add(childNode); 
    treeNode.Nodes.Add(childNode2); 
    treeView.Nodes.Add(treeNode); 
     
     
    RadTreeNode treeNode1 = new RadTreeNode("Node 1"); 
    RadTreeNode childNode1 = new RadTreeNode("Child of 1"); 
    RadTreeNode childNode12 = new RadTreeNode("Child 2 of 1"); 
     
    treeNode1.Nodes.Add(childNode1); 
    treeNode1.Nodes.Add(childNode12); 
    treeView.Nodes.Add(treeNode1); 
     
             
    treeView.MinimumSize = new Size(100, 350); 
    treeView.ThemeName = "ControlDefault"
    RadHostItem radHostItem = new RadHostItem(treeView); 
                 
    this.radComboBox1.Items.Add(radHostItem); 
     
    this.radComboBox1.ComboBoxElement.DropDownMinSize = new Size(310, 400); 

    I am using a regular RadTreeView control and a RadHostItem instance which hosts the RadTreeView. After that I am adding the RadHostItem to the Items collection of the RadComboBox.

    Note that due to some issues within the RadHostItem you will have to set the MinimumSize property of the RadTreeView and the DropDownMinSize property of the RadComboBox. The DropDownMinSize of the RadComboBox should be bigger than the RadTreeView's.

    I hope this will help you to achieve the desired behavior.

    Do not hesitate to write back if you need further assistance.

    Kind regards,
    Deyan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 22 Mar 2011 Link to this post

    Hello Joel Kraft,

    I am glad to inform you that in Q1 2011 we have introduced a major upgrade of RadTreeView control, which is now virtualized and fully customizable. Feel free to download the latest release and try it out. For more information on our latest release refer to this blog post.
     
    Best wishes,
    Stefan
    the Telerik team
Back to Top