TabPage.ImageIndex Property
.NET Framework 3.0
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)
Assembly: System.Windows.Forms (in system.windows.forms.dll)
[TypeConverterAttribute(typeof(ImageIndexConverter))] [LocalizableAttribute(true)] public int ImageIndex { get; set; }
/** @property */ public int get_ImageIndex () /** @property */ public void set_ImageIndex (int value)
public function get ImageIndex () : int public function set ImageIndex (value : int)
Not applicable.
Property Value
The zero-based index to the image in the TabControl.ImageList that appears on the tab. The default is -1, which signifies no image.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); tabControl1.Controls.Add(tabPage1); // 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; this.Controls.Add(tabControl1); } static void Main() { Application.Run(new Form1()); } }
import System.Drawing.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;
import System.Resources.*;
public class Form1 extends Form
{
public Form1()
{
IContainer components = new Container();
ResourceManager resources = new ResourceManager(Form1.class.ToType());
TabControl tabControl1 = new TabControl();
TabPage tabPage1 = new TabPage();
ImageList myImages = new ImageList(components);
tabControl1.get_Controls().Add(tabPage1);
// Displays images from myImages on the tabs of tabControl1.
tabControl1.set_ImageList(myImages);
// Specifies which image to display (on the tab of tabPage1) by its
// index.
tabPage1.set_ImageIndex(0);
tabPage1.set_Text("tabPage1");
myImages.set_ImageStream(((ImageListStreamer)(
resources.GetObject("myImages.ImageStream"))));
myImages.set_ColorDepth(ColorDepth.Depth8Bit);
myImages.set_ImageSize(new Size(16, 16));
myImages.set_TransparentColor(Color.get_Transparent());
this.get_Controls().Add(tabControl1);
} //Form1
public static void main(String[] args)
{
Application.Run(new Form1());
} //main
} //Form1
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.