Solved

Newbie question regarding treeview and listview

Posted on 2004-03-25
8
445 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

734 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