Question Get ListView Icon name

mansi sharma

Member
Joined
Mar 8, 2009
Messages
16
Programming Experience
Beginner
I associate the listview with the imagelist..Set property of listview SmallList to Imagelist..I want that on listview click. I get the icon name....But i m not getting how to get icon name..Mine code below--

VB.NET:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim lCount As Integer

        For lCount = 0 To 1
            If lCount = 0 Then
                ListView1.Items.Add("FIRST", lCount)
            End If

            If lCount = 1 Then
                ListView1.Items.Add("SEXCOND", lCount)
            End If


            Application.DoEvents()
        Next
    End Sub

    Private Sub ListView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.Click
        Dim lvw As ListView = CType(sender, ListView)

    End Sub

  
End Class
 
It is not possible to get the filename from the Image/Icon object. What you can do is add a string key to the images in ImageList and associate the ListViewItem with the image key instead of the image index.
 
sir Actualy I want to get the image index or either the image key of the Listview item that is selected...

I use the image Index
LvwChannels.SelectedItems(0).ImageIndex

BUt i do not get..What u r saying????? How to associate the images with string keys??/
 
I want to get the image index or either the image key of the Listview item that is selected
Read the ImageIndex or ImageKey property of the item.
How to associate the images with string keys??/
Set the ImageKey string property instead of the ImageIndex integer property. This can be done with the ListViewItemCollection.Add method, with the ListViewItem constructor, or with the ImageKey property of a ListViewItem instance.
 
Back
Top