Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Newbie question regarding treeview and listview

Posted on 2004-03-25
8
Medium Priority
?
471 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
LVL 10

Accepted Solution

by:
EBatista earned 2000 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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

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)…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

927 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