Export (0) Print
Expand All

ListViewItem.ImageIndex Property

Gets or sets the index of the image that is displayed for the item.

[Visual Basic]
Public Property ImageIndex As Integer
[C#]
public int ImageIndex {get; set;}
[C++]
public: __property int get_ImageIndex();
public: __property void set_ImageIndex(int);
[JScript]
public function get ImageIndex() : int;
public function set ImageIndex(int);

Property Value

The zero-based index of the image in the ImageList that is displayed for the item. The default is -1.

Exceptions

Exception Type Condition
ArgumentException The value specified is less than -1.

Remarks

The value of this property depends on the value of the ImageList property. Depending on the current value of the View property of the ListView control associated with the item, the ImageList used by the item could be one specified in the LargeImageList property or the SmallImageList property of the ListView control. If the View property is set to View.LargeIcons, the ImageList specified in the LargeImageList property is used; otherwise the ImageList specified in the SmallImageList property is used. It is recommended that the images defined in the ImageList specified in the SmallImageList have the same index positions as the images in the ImageList specified in the LargeImageList property. If the index positions are the same for both ImageList controls, you can set a single index value for the ImageIndex property and the appropriate image will be displayed regardless of the value of the View property of the ListView control.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

ListViewItem Class | ListViewItem Members | System.Windows.Forms Namespace | View | SmallImageList | LargeImageList

Show:
© 2014 Microsoft