Click here to Skip to main content
13,596,190 members
Click here to Skip to main content
Add your own
alternative version


30 bookmarked
Posted 23 Feb 2005

TreeView with Combo

, 23 Feb 2005
Rate this:
Please Sign up or sign in to vote.
A control that makes users able to select predefined values from a ComboBox instead of editing them inside a TreeView.

Sample Image


This control makes users able to select predefined values from a ComboBox instead of editing them inside a TreeView.


The reader is expected to have basic Object Oriented concepts and awareness in C# coding.

Using the code

Just add the control to your form in design mode or in run time. There is a property in the control called "combobox". It exposes the ComboBox that will appear when editing in the tree. Just fill the data source of the ComboBox. Do not forget to enable editing in the TreeView!!

The sample demo has all of this in brief.

All I did in the control was to inherit from the class "TreeView" of the .NET Framework and override the OnBeforeLabelEdit method of the class to show the ComboBox.

// Show combobox before editing in treeview //
protected override void OnBeforeLabelEdit (NodeLabelEditEventArgs e)
  current_tree_node = e.Node;
  tcombo.Bounds = e.Node.Bounds; tcombo.Show();

Then I handled the event SelectedIndexChanged of the ComboBox to set the TreeView label text with the selected text from the ComboBox.

// Show combobox text in the treeview label text
private void tcombo_SelectedIndexChanged(object sender, EventArgs e)
  current_tree_node.Text = tcombo.Text;


Version 1.0: 21/2/2005 (Posted).


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Ahmed Mahmoud Mohammed
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralThx a lot! Pin
Member 432469818-Sep-08 19:09
memberMember 432469818-Sep-08 19:09 
Generalvery good idea Pin
burlotjy12-Mar-07 4:36
memberburlotjy12-Mar-07 4:36 
GeneralGood Pin
BabuChellathurai8-Jan-07 23:13
memberBabuChellathurai8-Jan-07 23:13 
GeneralTreeNode as Text + ComboBox Pin
Aniket Salunkhe20-Sep-06 21:59
memberAniket Salunkhe20-Sep-06 21:59 
GeneralSolve this problem Pin
Dragon Pig23-May-05 17:07
memberDragon Pig23-May-05 17:07 
GeneralError!!!!! Pin
Dragon Pig23-May-05 16:58
memberDragon Pig23-May-05 16:58 
GeneralNeeds more (of everything) Pin
gxdata11-Mar-05 21:38
membergxdata11-Mar-05 21:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04-2016 | 2.8.180621.3 | Last Updated 24 Feb 2005
Article Copyright 2005 by Ahmed Mahmoud Mohammed
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid