Solved

Newbie question regarding treeview and listview

Posted on 2004-03-25
8
414 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
  • 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
 
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

910 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now