This is a migrated thread and some comments may be shown as answers.

Put TreeView in a ComboBox in win forms?

2 Answers 115 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Joel Kraft
Top achievements
Rank 2
Joel Kraft asked on 30 Jan 2009, 02:54 PM
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 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 02 Feb 2009, 03:46 PM
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.
0
Stefan
Telerik team
answered on 22 Mar 2011, 03:10 PM
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
Tags
Treeview
Asked by
Joel Kraft
Top achievements
Rank 2
Answers by
Deyan
Telerik team
Stefan
Telerik team
Share this question
or