?
Solved

ListView populated with Tool Strip Menu Items

Posted on 2011-03-24
1
Medium Priority
?
726 Views
Last Modified: 2012-05-11
Hi,
I have maneged to load Tool strip menu items in listview but how can I show coresponding image from tool strip next to the same in list view...
This would be the same as it's created eg in Excel for "Customize command" option in "Tools" menu..
Please help .... I would appreciate a lot...
Code for loading Toolstrip items below...
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For Each tsmi As ToolStripMenuItem In menuStrip1.Items

            getChildNodes(tsmi)

                    Next
    End Sub
    Private Sub getChildNodes(ByVal mi As ToolStripDropDownItem)
        For Each item As Object In mi.DropDownItems
            If item.[GetType]() Is GetType(ToolStripSeparator) Then
                Continue For
            End If
            Dim node As New ListViewItem(DirectCast(item, ToolStripDropDownItem).Text)
            ListView1.Items.Add(node)

            getChildNodes(DirectCast(item, ToolStripDropDownItem))
        Next
    End Sub

Open in new window

0
Comment
Question by:alsam
[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
1 Comment
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 2000 total points
ID: 35220875
Hi,

You can do it by using an ImageList control.

So you have to

1- Add an ImageList Control to your form

2-Add to the ImageList Control all the images of the ToolStripMenuItems on the Image Collection you can do this on the properties window of the ImageList on design mode

3-Assign to each ToolStripMenuItems the proper ImageIndex of the ImageList on the Imageindex property of the ToolStripMenuItem, but you have to do this by code

ToolStripMenuItem1.ImageIndex = 0
ToolStripMenuItem2.ImageIndex = 1
etc.

3-Assign to the ListView1 the ImageList control on the SmallImageList Property of the ListView1 for use small images or LargeImageList property for large images, you can do this in the properties window of the ListView on design mode

4-Change your code to assign the ImageIndex of the ToolStripMenu to the ListViewItem when you create it, change this line

Dim node As New ListViewItem(DirectCast(item, ToolStripDropDownItem).Text)

For this one

Dim node As New ListViewItem(DirectCast(item, ToolStripDropDownItem).Text, DirectCast(item, ToolStripDropDownItem).ImageIndex)

Hope that helps
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month7 days, 20 hours left to enroll

765 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