How to: Display Icons for the Windows Forms ListView Control

The Windows Forms ListView control can display icons from three image lists. The List, Details, and SmallIcon views display images from the image list specified in the SmallImageList property. The LargeIcon view displays images from the image list specified in the LargeImageList property. A list view can also display an additional set of icons, set in the StateImageList property, next to the large or small icons. For more information about image lists, see ImageList Component and How to: Add or Remove Images with the Windows Forms ImageList Component.

To display images in a list view

  1. Set the appropriate property—SmallImageList, LargeImageList, or StateImageList—to the existing ImageList component you wish to use.

    These properties can be set in the designer with the Properties window, or in code.

    listView1.SmallImageList = imageList1;
    
    
    ListView1.SmallImageList = ImageList1
    
    
  2. Set the ImageIndex or StateImageIndex property for each list item that has an associated icon.

    These properties can be set in code, or within the ListViewItem Collection Editor. To open the ListViewItem Collection Editor, click the ellipsis button (VisualStudioEllipsesButton screenshot) next to the Items property on the Properties window.

    // Sets the first list item to display the 4th image.
    listView1.Items[0].ImageIndex = 3;
    
    
    ' Sets the first list item to display the 4th image.
    ListView1.Items(0).ImageIndex = 3
    
    

See Also

ListView Control Overview
How to: Add and Remove Items with the Windows Forms ListView Control
How to: Add Columns to the Windows Forms ListView Control
How to: Add Custom Information to a TreeView or ListView Control (Windows Forms)
ImageList Component