NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

ButtonBase.ImageIndex

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

[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

A zero-based index which represents the image position in an ImageList. The default is-1.

Exceptions

Exception Type Condition
ArgumentException The assigned value is less than the lower bounds of the ImageIndex.

Remarks

When the ImageIndex or ImageList properties are set, the Image property is set to its default value, a null reference (in Visual Basic Nothing).

If the ImageList property changes and the ImageIndex property becomes greater than the upper bounds of the new ImageList, the ImageIndex property is set to its default value,-1.

Example [Visual Basic]

The following example uses the derived class, Button and sets the ImageList and ImageIndex properties. This code assumes an ImageList has been instanciated and a minimum of one Image has been assigned to it.

[Visual Basic]

Private Sub MySub()
   ' Create a new resource.
   Dim resources As System.Resources.ResourceManager = _
      New System.Resources.ResourceManager("Form1", "")
   
   ' Assign the ImageList to the button control.   
   Button1.ImageList = ImageList1
   ' Select the image from the ImageList (using the ImageIndex property).    
   Button1.ImageIndex = 0
   ' Get the image from the resource.
   Set Button1.Image = resources.GetObject("Button1.Image")
End Sub

See Also

ButtonBase Class | ButtonBase Members | System.WinForms Namespace | ImageList