Solved

Newbie question regarding treeview and listview

Posted on 2004-03-25
8
450 Views
Last Modified: 2008-01-09
I am new to programming learning about VB.NET.

I have a treeview which I added nodes in the TreeNode Editor. I would like to show the "child nodes" in Listview when I click on a node in treeview (like windows explorer). I saw many tutorials but I do not understand them. What is the EASIEST way to do this?
0
Comment
Question by:jantrey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 48

Expert Comment

by:Mikal613
ID: 10678746
when you click the treeview you cann just add the the text of the nodes to the Listview

OnCLick of the treeview
    Listview1.Add treeview nodes
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 10678759
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 10678764
You may have to register but its worth it
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 10

Accepted Solution

by:
EBatista earned 500 total points
ID: 10681286
hi jantrey, you could use the AfterSelect event to step through the Nodes collection of the selected node:

Private Sub TreeView1_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
        Me.ListView1.Items.Clear()
        Dim oNode As TreeNode

        For Each oNode In TreeView1.SelectedNode.Nodes
            Me.ListView1.Items.Add(oNode.Text)
        Next
End Sub


regards
0
 

Author Comment

by:jantrey
ID: 10681365
That's exactly what I needed!!!! Can I ask then...how do I add icons to the listview?
0
 
LVL 10

Expert Comment

by:EBatista
ID: 10681770
well the better way to do that is dragging an ImageList control from the toolbar to the Form, then select the new added imagelist control and in the property windows fill its Images property which is a collection of images, once you have done so, select the ListView control and in the property windows set its SmallImageList and LargeImageList properties to the ImageList control added in the previous step (also you can have two ImageList control, one for each property). Then you can modify the event handler:

Private Sub TreeView1_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
        Dim theItem As ListViewItem
        Dim oNode As TreeNode

        For Each oNode In TreeView1.SelectedNode.Nodes

            theItem = New ListViewItem(oNode.Text)
            theItem.ImageIndex = 0 'HERE setting the first image
            Me.ListView1.Items.Add(theItem)
        Next
End Sub


regards

0
 

Author Comment

by:jantrey
ID: 10682030
Thank you very much!!
0
 

Expert Comment

by:krinpit
ID: 10686959
Jantrey,

If you are going to develop this further, I suspect that eventually you will need a method of getting the system-default icon for each item.
This link explains everything, step by step:
http://www.codeguru.com/vb/gen/vb_misc/icons/article.php/c5597/
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question