TabControl.ImageList Property
Gets or sets the images to display on the control's tabs.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
To display an image on a tab, set the ImageIndex property of that TabPage. The ImageIndex acts as the index into the ImageList.
The following code example creates a TabControl with one TabPage. This example uses the ImageList property to display images, from the collection defined by the ImageList named myImages, on the tabs of tabControl1.
Use the System.Drawing, System.ComponentModel, System.Windows.Forms, and System.Resources namespaces 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(); // Declares and instantiates the ImageList object. ImageList myImages = new ImageList(components); tabControl1.Controls.Add(tabPage1); // Sets the images in myImages to display on the tabs of tabControl1. tabControl1.ImageList = myImages; tabPage1.ImageIndex = 0; tabPage1.Text = "tabPage1"; // Gets the handle that provides the data of myImages. myImages.ImageStream = ((ImageListStreamer)(resources.GetObject("myImages.ImageStream"))); // Sets properties of myImages. 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()); } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.