このタブに表示されているイメージのインデックスを取得または設定します。
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);
プロパティ値
タブに表示される TabControl.ImageList のイメージの 0 から始まるインデックス番号。既定値は -1 です。これはイメージがないことを示します。
例外
例外の種類 | 条件 |
---|---|
ArgumentException | ImageIndex の値が -1 未満です。 |
解説
ImageIndex は、 TabControl の関連付けられた ImageList 内のいずれかのイメージを示します。
使用例
[Visual Basic, C#, C++] 1 つの TabPage が配置された TabControl を作成する例を次に示します。この例では、 ImageIndex プロパティを使用して、 myImages
のどのイメージを tabPage1
のタブに表示するかを指定しています。
[Visual Basic, C#, C++] この例では、 System.Drawing 、 System.ComponentModel 、 System.Windows.Forms 、 System.Resources の各名前空間を使用します。
Imports System.Drawing
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Resources
Public Class Form1
Inherits Form
Public Sub New()
Dim components = New Container()
Dim resources As New ResourceManager(GetType(Form1))
Dim tabControl1 As New TabControl()
Dim tabPage1 As New TabPage()
Dim myImages As 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 = CType(resources.GetObject("myImages.ImageStream"), ImageListStreamer)
myImages.ColorDepth = ColorDepth.Depth8Bit
myImages.ImageSize = New Size(16, 16)
myImages.TransparentColor = Color.Transparent
Me.Controls.Add(tabControl1)
End Sub
Shared Sub Main()
Application.Run(New Form1())
End Sub
End Class
[C#]
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());
}
}
[C++]
using namespace System::Drawing;
using namespace System::ComponentModel;
using namespace System::Windows::Forms;
using namespace System::Resources;
public __gc class Form1 : public Form {
public:
Form1() {
IContainer* components = new System::ComponentModel::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 = S"tabPage1";
myImages->ImageStream = (dynamic_cast<ImageListStreamer*>(resources->GetObject(S"myImages.ImageStream")));
myImages->ColorDepth = ColorDepth::Depth8Bit;
myImages->ImageSize = System::Drawing::Size(16, 16);
myImages->TransparentColor = Color::Transparent;
this->Controls->Add(tabControl1);
}
};
int main() {
Application::Run(new Form1());
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
TabPage クラス | TabPage メンバ | System.Windows.Forms 名前空間 | ImageList