How to Add Icon on List View

This sample tutorial is showing you on how to add an icon or image on a List-view control on
your own program:
1.) you must Add Microsoft Windows Common Controls  6.0 (SP6) , to simply add a  
List-view Control and a  Image-list Control:

2.) set up the List-view Control on your form and also a  Image-list Control, to set a List-view 
on a General Tab set the View to Report, like show on the figure below:




















then you must add a Column Header for your column  Title like shown Below:























then click Apply button .

4.) to put an Image on a Image List just follow the steps below right-click the Image-list >
Properties and the Property Dialog will prompt


















at General Tab choose the size of the image you want  then at the Image Tab click Insert 

Picture like shown below: then the Select Picture Dialog will Prompt for you to add image
on a Image List, then click Open button the OK.
















then the simple code will look like this: the code will placed on the Form Load event

Private Sub Form_Load()
'first you must declare a variable that holds as Listitem
    Dim panoy As ListItem
'lv1 is the Listview name so we can initialized first like shown
'below
          lv1.SmallIcons = ImageList1
'set the listitem 
              Set panoy = lv1.ListItems.Add(, , "Panoy")
'and the icon will down to this code calling the image
'on a imagelist and the index of image is 1
        panoy.SmallIcon = 1       
End Sub

and the output  will look like this:























Happy Coding (^_^)
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati

Leave a comment

Copyright @ Codes-47.Blogspot.Com. Powered by Blogger.