Hello everyone
we use a listview box and we add some path's of the files in list
and now we want to show the file icon with in file path
example:
listview1.item.add " D:\test.txt"
listview1.item.add " D:\picture.jpg"
now we want to show these files icon in my listview
please tell me what i do ?
thanks

Recommended Answers

All 7 Replies

Add icon to imagelist.
use icon picture (.ico) and change the "view" to "0-lvwIcon" on listview properties
assign icon image from imagelist to listview.

Jx Man thanks for attaching this project
please dont mind but i want to do this
example:
we use a listview and make two column tabs
listview1.ListItems.Add , , "D:\test.txt"
Now we want to show this file icon in left or right side in the listview
when add any path of file in listview then it will show his file icon
please help

you mean every added any path then there are icon set in left side of that items?

Add one icon with dimension 16x16 to Imagelist.
Then add this code :

Private Sub Command1_Click()
On Error Resume Next

    With ListView1
        Set .Icons = ImageList
        Set .SmallIcons = ImageList
        Set View = .ListItems.Add(, , , 1, 1) ' Icon Added
        View.SubItems(1) = "This/Where/Path/Added/" & .ListItems.Count 'Path Added
        View.SubItems(2) = "Size " & .ListItems.Count 'Size Added
    End With
End Sub

Thanks
but you mean every file which we add the list box first we added all icons them

Yes. It means every you added new path the same icon will shown.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.