• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 345
  • Last Modified:

ListView

i am making a download manager, and am wondering how i can put an icon on the left side of a listview, kinda like they do in kazaa. I have multiple columns, so i'd imagine it'd have to be in the first column...but i dont know how to add an icon
0
boss302_lp
Asked:
boss302_lp
  • 3
  • 2
1 Solution
 
sazhagianambiCommented:
Hi,

To Add Icons in Header Place one ImageList. Load it With Icons You Want. Place The Follwoing  Code to set Icon

   ListView1.ColumnHeaderIcons = ImageList1
   ListView1.View = lvwReport
   
   Dim objColumnHeader
   Set objColumnHeader = ListView1.ColumnHeaders.Add()
   objColumnHeader.Text = "Example"
   objColumnHeader.Width = 2000
   objColumnHeader.Alignment = lvwColumnLeft
   objColumnHeader.Icon = 1

Regards,
Nambi
0
 
cocomobasicCommented:
hi

Assuming that you used Microsoft Windows Common Controls 6.0:

1. First, place a listview control and an imagelist control on the form.
2. Create the columns for the listview.
3. Add your desired icons to the imagelist.

type this code --------

Private Sub Form_Load()

    ' bind the listview and the imagelist    
    ListView1.SmallIcons = ImageList1
    ListView1.Icons = ImageList1
   
    ListView1.ListItems.Add , , "My Listview With Icon", 1, 1

End Sub


note: the 1, 1 on the add method is the index of the icon you placed on your listview.
     meaning, if you want the second icon that you placed, you should enter 2, 2
0
 
cocomobasicCommented:
hi

Assuming that you used Microsoft Windows Common Controls 6.0:

1. First, place a listview control and an imagelist control on the form.
2. Create the columns for the listview.
3. Add your desired icons to the imagelist.

type this code --------

Private Sub Form_Load()

    ' bind the listview and the imagelist    
    ListView1.SmallIcons = ImageList1
    ListView1.Icons = ImageList1
   
    ListView1.ListItems.Add , , "My Listview With Icon", 1, 1

End Sub


note: the 1, 1 on the add method is the index of the icon you placed on your listview.
     meaning, if you want the second icon that you placed, you should enter 2, 2

sorry for the note; its not the index of the listview, but the index of the icons you placed on your imagelist
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
boss302_lpAuthor Commented:
what if i already have items in the list, will this just automatically put it in front of all items, or do i have to make it do this each time an item is added?
0
 
cocomobasicCommented:
hi again,

you must do this in every item you add. example:

Private Sub Form_Load()

   ' bind the listview and the imagelist    
   ListView1.SmallIcons = ImageList1
   ListView1.Icons = ImageList1
   
   ' 1st item
   ListView1.ListItems.Add , , "My Listview With Icon 1", 1, 1

   ' 2nd item
   ListView1.ListItems.Add , , "My Listview With Icon 2", 1, 1

   ' 3rd item
   ListView1.ListItems.Add , , "My Listview With Icon 3", 1, 1

End Sub

just change the 1, 1 to the index of the image in the imagelist to give them
different icons. that is if you want to.. hope this helps
0
 
boss302_lpAuthor Commented:
thanks a bunch
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now