![]() |
|
[.NET] [VB.NET]How we can Create Tree Menu in ComboBox - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] [VB.NET]How we can Create Tree Menu in ComboBox (/showthread.php?tid=407298) |
[VB.NET]How we can Create Tree Menu in ComboBox - codepoet - May 7, 2010 Author: DevASP Tutorial: Crow407 In this tutorial I Will Explain How we can Create Tree Menu Which is Embeded in ComboBox using VB.Net. This UserControl is a ComboBox control that has its dropdown window replaced with a TreeView control. Handling the mouse, the keyboard and the focusing was a bit tricky and the control is not 100% perfect but it works just fine. Two issues are unresolved, but they were not important to me: firstly, since the TreeView is a child control it cannot be drawn outside the form; and secondly, a ComboBox.CloseUp call must be placed on the Form.Click event since the control does not monitor its own parent. For diligent people it should be relatively easy to adjust this control to their own needs, and even to replace the TreeView control with something else and build other types of specialized ComboBoxes. To create Combo box with Tree Menu Follow Some Steps and Understand Code Below. 1. Create new application Using File menu and Choose vb.net project. Now you will see the form Open in your application. 2. Now enter the routine below Against the load event of form. This routine infact Set some initial TreeView properties.Creating the tree nodes while the TreeView is visible avoids the bug that shows a horizontal scrollbar on the bottom of the tree. Code Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load3. Now select the click event of form the auto generated routine is appear below.Write the line of code this line actually this should be handled by the ComboBoxTree itself, but the current version of the control does not handle this. Code Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click4. now double click on button the auto generated routine is appear.Write the code below which check Selected node is exist or not. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Code If Me.ComboBoxTree1.SelectedNode Is Nothing Then5. Select the Combo box after Select event Write few lines.it sets some properties of Combo box. Code Private Sub ComboBoxTree1_AfterSelect(ByVal sender As Object) Handles ComboBoxTree1.AfterSelectCode Private Sub ComboBoxTree1_BeforeSelect(ByVal sender As Object, ByVal Node As System.Windows.Forms.TreeNode, ByRef Cancel As Boolean) Handles ComboBoxTree1.BeforeSelectCode Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.ClickIf You Like this tutorial, please check out my other tutorials by clicking ==> H3R3 [img]http://i685.photobucket.com/albums/vv215/blackpearl4/THANKS.gif[/img]
* - codepoet - May 7, 2010 bump good tutorial in my opinion * - Aeonhack Archivist - May 7, 2010 Pretty good. I have been wondering how to do this. * - jaikrishna - May 7, 2010 That was good. Yet, If it was so long, You could have some pics here. * - codepoet - May 8, 2010 (May 7, 2010 07:42 PM)alecn1519 Wrote: Pretty good. I have been wondering how to do this. im glad this helped you... (May 7, 2010 07:53 PM)jaikrishna Wrote: That was good. Yet, If it was so long, You could have some pics here. pictures? what for this is some of the easyes things you can do on here... |