473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,395 developers and data experts.

Adding Items to Treeview Manually.

debasisdas
8,127 Expert 4TB
Select Microsoft windows common controls 6.0 (SP6) from components
Add a TreeView control to the form.
Add a ImageList control to the form.
Add some bitmaps to the imagelist.
Set the name of image list to the Image List property of the Tree view control.

Add this sample code to the form
=============================
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Dim Node1 As Node, Node2 As Node
  3. Dim Node3 As Node, Node4 As Node
  4.  
  5. Set Node1 = tv1.Nodes.Add
  6. tv1.Nodes(1).Text = "Node 1"
  7. tv1.Nodes(1).Key = "Node 1"
  8. tv1.Nodes(1).Image = "closed"
  9.  
  10. Set Node2 = tv1.Nodes.Add("Node 1", tvwChild, "Node 2")
  11. tv1.Nodes(2).Text = "Node 2"
  12. tv1.Nodes(2).Key = "Node 2"
  13. tv1.Nodes(2).Image = "leaf"
  14.  
  15. Set Node3 = tv1.Nodes.Add("Node 1", tvwChild, "Node 3")
  16. tv1.Nodes(3).Text = "Node 3"
  17. tv1.Nodes(3).Key = "Node 3"
  18. tv1.Nodes(3).Image = "closed"
  19.  
  20. Set Node4 = tv1.Nodes.Add("Node 3", tvwChild, "Node 4")
  21. tv1.Nodes(4).Text = "Node 4"
  22. tv1.Nodes(4).Key = "Node 4"
  23. tv1.Nodes(4).Image = "leaf"
  24. End Sub
  25.  
  26. Private Sub tv1_Collapse(ByVal Node As MSComctlLib.Node)
  27. Node.Image = "closed"
  28. End Sub
  29.  
  30. Private Sub tv1_Expand(ByVal Node As MSComctlLib.Node)
  31. Node.Image = "open"
  32. End Sub
  33.  
  34.  

NOTE--open,closed,leaf are the Key peoperty of the images in the image list
Oct 17 '07 #1
0 8744

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Aaron Queenan | last post by:
How can I use the designer to add a context menu to a class which inherits from a control, e.g. treeview, without adding the context menu to a form? For example, to add a context menu with...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
10
by: tmaster | last post by:
When I try to dynamically add a second sub menu item to this ContextMenu item, I get an error 'Specified argument was out of the range of valid values'. Private Sub mnuTopics_Show_Select(ByVal...
4
by: pmcguire | last post by:
I have a treeview with a lot of nodes. I want to load only the nodes that are initially visible when the form loads, and then continue to populate it in background and/or when the nodes are required...
7
by: Progalex | last post by:
Hi everybody! I have a listview and a treeview in a form . With an OpenDialog I let the user select multiple files and then these files are added to the listview with the complete pathname,...
3
by: Ray Booysen | last post by:
Hi all I have a treeview bound to a sitemap. Once the user is logged in, I'm wanting the menu to expand to include additional items from a database while retaining the items in the sitemap. Is...
6
by: =?Utf-8?B?QnJhZA==?= | last post by:
VS,VB 2005 I have a treeview which i load data into in the forms load event Adding Nodes and Children to the parent nodes works fine to add a parent:...
0
debasisdas
by: debasisdas | last post by:
This sample code displays employee name in the treeview control from the emp table of Scott schema in oracle database. To start with Select Microsoft windows common controls 6.0 (SP6) from...
0
by: metricspaces | last post by:
Hi, I'm using VB6 and the TreeView from "Microsoft Windows Common Controls.". Due to the bug http://support.microsoft.com/kb/182231 it is not possible to add more than 32767 nodes to the tree. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.