ImageList.ImageCollection.Item[] Property

Definition

Gets or sets an Image in an existing ImageList.

Overloads

Item[String]

Gets an Image with the specified key from the collection.

Item[Int32]

Gets or sets an Image at the specified index within the collection.

Item[String]

Source:
ImageList.ImageCollection.cs
Source:
ImageList.ImageCollection.cs
Source:
ImageList.ImageCollection.cs

Gets an Image with the specified key from the collection.

C#
public System.Drawing.Image this[string key] { get; }
C#
public System.Drawing.Image? this[string key] { get; }

Parameters

key
String

The name of the image to retrieve from the collection.

Property Value

The Image with the specified key.

Remarks

The name of an image corresponds to its key in the ImageList.ImageCollection. The key comparison is not case-sensitive.

If an image with the specified key is not found, the value of the Item[] property is null.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

Item[Int32]

Source:
ImageList.ImageCollection.cs
Source:
ImageList.ImageCollection.cs
Source:
ImageList.ImageCollection.cs

Gets or sets an Image at the specified index within the collection.

C#
[System.ComponentModel.Browsable(false)]
public System.Drawing.Image this[int index] { get; set; }

Parameters

index
Int32

The index of the image to get or set.

Property Value

The image in the list specified by index.

Attributes

Exceptions

The index is less than 0 or greater than or equal to Count.

image is not a Bitmap.

The image to be assigned is null or not a Bitmap.

The image cannot be added to the list.

Remarks

The returned bitmap is a copy of the original image and should be disposed of using the Image.Dispose method.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9