473,830 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Items to Treeview Manually.

debasisdas
8,127 Recognized Expert Expert
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,lea f are the Key peoperty of the images in the image list
Oct 17 '07 #1
0 8798

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

Similar topics

4
14191
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 "Select All" and "Clear Selection" to a checked list box? Thanks, Aaron Queenan.
4
5492
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 dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last selection and displays actual articles for display. Adding the controls and getting everything...
10
21336
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 sender As System.Object, _ ByVal e As System.EventArgs) _ Handles mnuTopics_Show.Select Dim mShowMenuItem As MenuItem mShowMenuItem = DirectCast(sender, MenuItem)
4
2315
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 by the user either scrolling or performing some other action that would move the treeview window to a particular "unloaded" node in the treeview Any advice on how to go about this? It seems I need a way of sensing a scroll event in the treeview...
7
10420
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, while they are added to the treeview without the path (only file name). I'd like the user would be able to remove multiple items selecting filenames from the listview. So, items should be removed both from the listview and the treeview. How can I do...
3
2267
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 this possible. For example. My menu has an item called "Books" defined in the sitemap. Once the user logs in, I want sub menu-items to be created under books with all
6
2792
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: Me.tvGroups.Nodes.Add(GroupDataRow(0)("MenuGroupID").ToString, GroupDataRow(0)("GroupLabel")) to add a child to a Parent:
0
16308
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 components Add a TreeView and a ListView control to the form. Add this sample code to the form ========================== Dim con As New ADODB.Connection
0
1263
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. I want to add 100,000's items to the TreeView. Is there anywork around for this problem? Is there any other implementation of TreeView that I can use with VB6 and does not suffer from this problem?
0
9786
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10769
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10523
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10199
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9312
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6948
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4409
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3956
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3073
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.