次の方法で共有


TabControl.ImageList プロパティ

コントロールのタブ上に表示するイメージを取得または設定します。

Public Property ImageList As ImageList
[C#]
public ImageList ImageList {get; set;}
[C++]
public: __property ImageList* get_ImageList();public: __property void set_ImageList(ImageList*);
[JScript]
public function get ImageList() : ImageList;public function set ImageList(ImageList);

プロパティ値

タブ上に表示するイメージを指定する ImageList

解説

タブ上にイメージを表示するには、該当する TabPageImageIndex プロパティを設定します。 ImageIndex は、 ImageList へのインデックスの役割を果たします。

使用例

[Visual Basic, C#, C++] 1 つの TabPage が配置された TabControl を作成する例を次に示します。 ImageList プロパティを使用して、 myImages という名前の ImageList によって定義されているコレクションから、 tabControl1 のタブ上にイメージを表示する例を次に示します。

[Visual Basic, C#, C++] この例では、 System.DrawingSystem.ComponentModelSystem.Windows.FormsSystem.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()

        ' Declares and instantiates the ImageList object.
        Dim myImages As 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 = CType(resources.GetObject("myImages.ImageStream"), ImageListStreamer)

        ' Sets properties of myImages. 
        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();

        // 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());
    }
}

[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();

        // 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 = S"tabPage1";

        // Gets the handle that provides the data of myImages.
        myImages->ImageStream = (dynamic_cast<ImageListStreamer*>(resources->GetObject(S"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(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 ファミリ

参照

TabControl クラス | TabControl メンバ | System.Windows.Forms 名前空間 | ImageList