TabPage.ImageIndex Property


Gets or sets the index to the image displayed on this tab.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public int ImageIndex { get; set; }

Property Value

Type: System.Int32

The zero-based index to the image in the TabControl.ImageList that appears on the tab. The default is -1, which signifies no image.

Exception Condition

The ImageIndex value is less than -1.

The ImageIndex points to an image in the associated ImageList of the TabControl.

The following code example creates a TabControl with one TabPage. This example uses the ImageIndex property to specify which image from myImages displays on the tab of tabPage1.

Use the System.Drawing, System.ComponentModel, System.Windows.Forms, and System.Resources namespace for this example.

using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.Resources;

public class Form1 : Form
    public Form1()
        IContainer components = new Container();
        ResourceManager resources = new ResourceManager(typeof(Form1));
        TabControl tabControl1 = new TabControl();
        TabPage tabPage1 = new TabPage();
        ImageList myImages = new ImageList(components);


        // Displays images from myImages on the tabs of tabControl1.
        tabControl1.ImageList = myImages;

        // Specifies which image to display (on the tab of tabPage1) by its index.
        tabPage1.ImageIndex = 0;

        tabPage1.Text = "tabPage1";

        myImages.ImageStream = ((ImageListStreamer)(resources.GetObject("myImages.ImageStream")));
        myImages.ColorDepth = ColorDepth.Depth8Bit;
        myImages.ImageSize = new Size(16, 16);
        myImages.TransparentColor = Color.Transparent;


    static void Main() 
        Application.Run(new Form1());

.NET Framework
Available since 1.1
Return to top