System.Windows.Forms.ButtonBase.ImageIndex Property

Gets or sets the image list index value of the image displayed on the button control.

Syntax

[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)]
[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter))]
[System.ComponentModel.Editor("System.Windows.Forms.Design.ImageIndexEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]
[System.ComponentModel.DefaultValue(-1)]
[System.ComponentModel.Localizable(true)]
public int ImageIndex { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

When the ButtonBase.ImageIndex or ButtonBase.ImageList properties are set, the ButtonBase.Image property is set to its default value, null.

Note:

If the ButtonBase.ImageList property value is changed to null, the ButtonBase.ImageIndex property returns its default value, -1. However, the assigned ButtonBase.ImageIndex value is retained internally and used when another System.Windows.Forms.ImageList object is assigned to the ButtonBase.ImageList property. If the new System.Windows.Forms.ImageList assigned to the ButtonBase.ImageList property has an System.Windows.Forms.ImageList.ImageCollection.Count property value that is less than or equal to the value assigned to the ButtonBase.ImageIndex property minus one (to account for the collection being a zero-based index), the ButtonBase.ImageIndex property value is adjusted to one less than the System.Windows.Forms.ImageList.ImageCollection.Count property value. For example, consider a button control whose System.Windows.Forms.ImageList has three images and whose ButtonBase.ImageIndex property is set to 2. If a new System.Windows.Forms.ImageList that has only two images is assigned to the button, the ButtonBase.ImageIndex value changes to 1.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0