TabControl::ImageList Property
.NET Framework (current version)
Gets or sets the images to display on the control's tabs.
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 namespace System::Drawing; using namespace System::ComponentModel; using namespace System::Windows::Forms; using namespace System::Resources; public ref class Form1: public Form { public: Form1() { IContainer^ components = gcnew System::ComponentModel::Container; ResourceManager^ resources = gcnew ResourceManager( Form1::typeid ); TabControl^ tabControl1 = gcnew TabControl; TabPage^ tabPage1 = gcnew TabPage; // Declares and instantiates the ImageList Object*. ImageList^ myImages = gcnew 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 = (dynamic_cast<ImageListStreamer^>(resources->GetObject( "myImages.ImageStream" ))); // Sets properties of myImages. myImages->ColorDepth = ColorDepth::Depth8Bit; myImages->ImageSize = System::Drawing::Size( 16, 16 ); myImages->TransparentColor = Color::Transparent; this->Controls->Add( tabControl1 ); } }; int main() { Application::Run( gcnew Form1 ); }
.NET Framework
Available since 1.1
Available since 1.1
Show: