Click here to Skip to main content
Licence 
First Posted 27 Jan 2004
Views 97,061
Downloads 650
Bookmarked 61 times

ComboBoxTree

By Gabe Anguiano | 2 Feb 2004
A treeview control that drops down much like a combobox.
1 vote, 5.0%
1
1 vote, 5.0%
2
4 votes, 20.0%
3
6 votes, 30.0%
4
8 votes, 40.0%
5
4.26/5 - 20 votes
1 removed
μ 3.78, σa 2.01 [?]

Sample Image

Introduction

The ComboBoxTree control expands on Gevik Babakhani's DropDown Treeview control. Nearly 85% of the code has been rewritten. This updated control provides the following enhancements:

  • Treeview can be sized beyond the width of its parents and the form.
  • The sizing grip functionality is more consistent with standard Windows sizing grips.
  • Node selection populates the box when it is a root node, the SelectionSeparator property assigns the separator (i.e. a SelectionSeperator that is a period '.' would generate something like: Node0.subnode1.subnode2.rootnode).
  • Better design-time support including the standard treeview WYSIWYG editor.
  • The selected node box is editable and accessible as a property - however there is no validation on this value when set manually.
  • Simplified, by using regions and less method calls.

Please feel free to post comments, questions or criticism. This is my first Windows control, so feedback is appreciated.

Background

I needed a control for a project that required multiple treeviews but had very limited form space. When I found Gevik's DropDown TreeView, I was relieved to find what I was looking for but soon ran into problems that required attention and hours of code updating.

Originally, I didn't intend to redistribute the updated control, but I wanted to give back as a way of saying thanks. Thanks goes out to The Code Project and the original author - thanks Gevik Babakhani ;-)

To use the control, simply add the ComboBoxTree.dll file to your toolbox and drop the control onto your form. The control should provide most of the treeview functionality you require.

Points of Interest

I was able to get around the "sizing beyond parent" problem by adding the treeview to its own borderless form. My next problem involved making the sizing grip work correctly. I was able to get this going by calculating the offset of the mouse within the sizing grip along with the absolute mouse position and the location of the form containing the treeview. My final big problem was the sizing grip when scroll bars showed. Disabling scroll bars wasn't a solution so my only alternative was to add a margin of space on the bottom and right-hand side. A bit different but definitely functional!

History

  • 01/26/04 Version 1.0 submitted.
  • 02/02/04 Version 1.2 submitted, changes include:
    • Text property is now overridden.
    • AbsoluteChildrenSelectableOnly property option now available, users can now select end nodes only or all nodes.
    • Public ValidateText method now available to validate manually entered text.
    • SelectionSeparator now called BranchSeparater.
    • Minor toolbox category changes.

License

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

Gabe Anguiano



United States United States

Member


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionHow to show image of the selected tree item in combobox PinmemberRui Frazao7:07 9 Jun '10  
GeneralCheckbox With Every Node PinmemberFarid_Bilal21:58 26 Feb '09  
QuestionHow to populate tree with data from datatable ? Pinmemberloverboy234:49 12 Jul '08  
QuestionHow can i get DropDownStyle like combobox? PinmemberMember 13766004:07 10 Apr '08  
GeneralBranchSeparator as String, DropDownHeight, ... Pinmemberfraveu10:53 27 Sep '07  
GeneralRe: BranchSeparator as String, DropDownHeight, ... Pinmemberfraveu10:55 27 Sep '07  
GeneralFlatStyle System Pinmemberjake07211:30 23 Aug '07  
GeneralRe: FlatStyle System PinmemberLAcike@sk0:40 1 Jul '08  
GeneralAfterSelect event Pinmembermayank_max107:50 4 Jun '07  
GeneralRe: AfterSelect event Pinmembermayank_max10:07 4 Jun '07  
GeneralRe: AfterSelect event Pinmembermayank_max10:13 4 Jun '07  
GeneralRe: AfterSelect event PinmemberJossGP0:41 12 Oct '07  
QuestionHow to sort the ComboBoxTree Pinmembersatisht21:18 23 May '07  
GeneralNeed this in VB.net [modified] - no longer needed PinmemberVortran11:51 9 Oct '06  
GeneralBug Deteced !! PinmemberH1berto Ferreira2:44 3 Jan '06  
Generalform lostfocus problem PinmemberTurboWang15:50 10 Mar '04  
GeneralRe: form lostfocus problem PinmemberGabe Anguiano10:59 12 Mar '04  
GeneralExcellent ! PinmemberBillWoodruff16:52 10 Feb '04  
GeneralButton on title bar Pinmembersylvain22224:05 3 Feb '04  
GeneralRe: Button on title bar Pinmemberasm438:10 3 Feb '04  
GeneralRe: Button on title bar PinmemberGabe Anguiano12:46 3 Feb '04  
GeneralYou can find many useful ideas in my control too :) PinmemberAlex Kucherenko22:51 2 Feb '04  
GeneralRe: You can find many useful ideas in my control too :) PinmemberGabe Anguiano12:40 3 Feb '04  
Generalnice functionality except you have to select end node PinmemberAshley van Gerven22:47 28 Jan '04  
GeneralRe: nice functionality except you have to select end node PinsussGabe Anguiano (obsidience)8:23 29 Jan '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web04 | 2.5.120210.1 | Last Updated 3 Feb 2004
Article Copyright 2004 by Gabe Anguiano
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid