Imagelistとは? わかりやすく解説

ImageList イベント


ImageList クラス

Image オブジェクトコレクション管理するメソッド提供します。このクラス継承できません。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public NotInheritable Class
 ImageList
    Inherits Component
public final class ImageList extends Component
public final class ImageList extends
 Component
解説解説
使用例使用例

イメージ選択削除表示方法次のコード例示します

Imports System
Imports System.Drawing
Imports System.ComponentModel
Imports System.Windows.Forms

Public Class Form1
    Inherits System.Windows.Forms.Form
    Private listBox1 As System.Windows.Forms.ListBox
    Private label3 As System.Windows.Forms.Label
    Private WithEvents button1 As
 System.Windows.Forms.Button
    Private WithEvents button2 As
 System.Windows.Forms.Button
    Private WithEvents button3 As
 System.Windows.Forms.Button
    Private WithEvents button4 As
 System.Windows.Forms.Button
    Private pictureBox1 As System.Windows.Forms.PictureBox
    Private imageList1 As System.Windows.Forms.ImageList
    Private openFileDialog1 As System.Windows.Forms.OpenFileDialog
    Protected myGraphics As Graphics
    Private panel1 As System.Windows.Forms.Panel
    Private label5 As System.Windows.Forms.Label
    Private currentImage As Integer
 = 0

    Public Sub New()
        imageList1 = New ImageList()

        InitializeComponent()
        ' The default image size is 16 x 16, which sets up a larger
        ' image size. 
        imageList1.ImageSize = New Size(255, 255)
        imageList1.TransparentColor = Color.White

        ' Assigns the graphics object to use in the draw options.
        myGraphics = Graphics.FromHwnd(panel1.Handle)

    End Sub 'New

    Private Sub InitializeComponent()

        Me.listBox1 = New System.Windows.Forms.ListBox()
        Me.label3 = New System.Windows.Forms.Label()
        Me.button1 = New System.Windows.Forms.Button()
        Me.button2 = New System.Windows.Forms.Button()
        Me.button3 = New System.Windows.Forms.Button()
        Me.button4 = New System.Windows.Forms.Button()
        Me.pictureBox1 = New System.Windows.Forms.PictureBox()
        Me.openFileDialog1 = New System.Windows.Forms.OpenFileDialog()
        Me.panel1 = New System.Windows.Forms.Panel()
        Me.label5 = New System.Windows.Forms.Label()
        Me.SuspendLayout()

        Me.listBox1.Location = New System.Drawing.Point(16,
 16)
        Me.listBox1.Size = New System.Drawing.Size(400,
 95)
        Me.listBox1.TabIndex = 0

        Me.label3.Location = New System.Drawing.Point(24,
 168)
        Me.label3.Text = "label3"

        Me.button1.Location = New System.Drawing.Point(96,
 128)
        Me.button1.Size = New System.Drawing.Size(104,
 23)
        Me.button1.Text = "Show Next Image"

        Me.button2.Location = New System.Drawing.Point(208,
 128)
        Me.button2.Size = New System.Drawing.Size(104,
 23)
        Me.button2.Text = "Remove Image"

        Me.button3.Location = New System.Drawing.Point(320,
 128)
        Me.button3.Text = "Clear List"

        Me.button4.Location = New System.Drawing.Point(16,
 128)
        Me.button4.Text = "Open Image"

        Me.pictureBox1.Location = New System.Drawing.Point(328,
 232)
        Me.pictureBox1.Size = New System.Drawing.Size(336,
 192)

        Me.imageList1.ImageSize = New System.Drawing.Size(16,
 16)
        Me.imageList1.TransparentColor = System.Drawing.Color.Transparent

        Me.panel1.Location = New System.Drawing.Point(8,
 240)
        Me.panel1.Size = New System.Drawing.Size(296,
 184)

        Me.label5.Location = New System.Drawing.Point(168,
 168)
        Me.label5.Size = New System.Drawing.Size(312,
 40)
        Me.label5.Text = "label5"

        Me.ClientSize = New System.Drawing.Size(672,
 461)
        Me.Controls.Add(label5)
        Me.Controls.Add(panel1)
        Me.Controls.Add(pictureBox1)
        Me.Controls.Add(button4)
        Me.Controls.Add(button3)
        Me.Controls.Add(button2)
        Me.Controls.Add(button1)
        Me.Controls.Add(label3)
        Me.Controls.Add(listBox1)
        Me.ResumeLayout(False)
    End Sub

    ' Display the image.
    Private Sub button1_Click(ByVal
 sender As Object, _
        ByVal e As System.EventArgs) Handles
 button1.Click

        If imageList1.Images.Empty <> True
 Then
            If imageList1.Images.Count - 1 > currentImage Then
                currentImage += 1
            Else
                currentImage = 0
            End If
            panel1.Refresh()

            ' Draw the image in the panel.
            imageList1.Draw(myGraphics, 10, 10, currentImage)

            ' Show the image in the PictureBox.
            pictureBox1.Image = imageList1.Images(currentImage)
            label3.Text = "Current image is " + currentImage.ToString
            listBox1.SelectedIndex = currentImage
            label5.Text = "Image is " + listBox1.Text
        End If
    End Sub

    ' Remove the image.
    Private Sub button2_Click(ByVal
 sender As Object, _
        ByVal e As System.EventArgs) Handles
 button2.Click

        imageList1.Images.RemoveAt(listBox1.SelectedIndex)
        listBox1.Items.Remove(listBox1.SelectedItem)
    End Sub

    ' Clear all images.
    Private Sub button3_Click(ByVal
 sender As Object, _
        ByVal e As System.EventArgs) Handles
 button3.Click
        imageList1.Images.Clear()
        listBox1.Items.Clear()
    End Sub

    ' Find an image.
    Private Sub button4_Click(ByVal
 sender As Object, _
        ByVal e As System.EventArgs) Handles
 button4.Click

        openFileDialog1.Multiselect = True
        If openFileDialog1.ShowDialog() = DialogResult.OK Then
            If Not (openFileDialog1.FileNames
 Is Nothing) Then
                Dim i As Integer
                For i = 0 To openFileDialog1.FileNames.Length
 - 1
                    addImage(openFileDialog1.FileNames(i))
                Next i
            Else
                addImage(openFileDialog1.FileName)
            End If
        End If
    End Sub

    Private Sub addImage(ByVal
 imageToLoad As String)
        If imageToLoad <> ""
 Then
            imageList1.Images.Add(Image.FromFile(imageToLoad))
            listBox1.BeginUpdate()
            listBox1.Items.Add(imageToLoad)
            listBox1.EndUpdate()
        End If
    End Sub

    Public Shared Sub Main(ByVal
 args() As String)
        Application.Run(New Form1())
    End Sub
End Class
namespace myImageRotator
{
    using System;
    using System.Drawing;
    using System.ComponentModel;
    using System.Windows.Forms;
 
    public class Form1 : System.Windows.Forms.Form
    {
        private System.ComponentModel.IContainer components;
        private System.Windows.Forms.ListBox listBox1;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Button button2;
        private System.Windows.Forms.Button button3;
        private System.Windows.Forms.Button button4;
        private System.Windows.Forms.PictureBox pictureBox1;
        private System.Windows.Forms.ImageList imageList1;
        private System.Windows.Forms.OpenFileDialog openFileDialog1;
        protected Graphics myGraphics;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.Label label5;
        private int currentImage = 0;
 
        public Form1()
        {
            InitializeComponent();
            imageList1 = new ImageList () ;

            // The default image size is 16 x 16, which sets up a larger
            // image size. 
            imageList1.ImageSize = new Size(255,255);
            imageList1.TransparentColor = Color.White;

            // Assigns the graphics object to use in the draw options.
            myGraphics = Graphics.FromHwnd(panel1.Handle);
        }
 
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.listBox1 = new System.Windows.Forms.ListBox();
            this.label3 = new System.Windows.Forms.Label();
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.button4 = new System.Windows.Forms.Button();
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.imageList1 = new System.Windows.Forms.ImageList(this.components);
            this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
            this.panel1 = new System.Windows.Forms.Panel();
            this.label5 = new System.Windows.Forms.Label();
            this.SuspendLayout();

            this.listBox1.Location = new System.Drawing.Point(16,
 16);
            this.listBox1.Size = new System.Drawing.Size(400,
 95);
            this.listBox1.TabIndex = 0;

            this.label3.Location = new System.Drawing.Point(24,
 168);
            this.label3.Text = "label3";

            this.button1.Location = new System.Drawing.Point(96,
 128);
            this.button1.Size = new System.Drawing.Size(104,
 23);
            this.button1.Text = "Show Next Image";
            this.button1.Click += new System.EventHandler(this.button1_Click);

            this.button2.Location = new System.Drawing.Point(208,
 128);
            this.button2.Size = new System.Drawing.Size(104,
 23);
            this.button2.Text = "Remove Image";
            this.button2.Click += new System.EventHandler(this.button2_Click);

            this.button3.Location = new System.Drawing.Point(320,
 128);
            this.button3.Text = "Clear List";
            this.button3.Click += new System.EventHandler(this.button3_Click);

            this.button4.Location = new System.Drawing.Point(16,
 128);
            this.button4.Text = "Open Image";
            this.button4.Click += new System.EventHandler(this.button4_Click);

            this.pictureBox1.Location = new
 System.Drawing.Point(328, 232);
            this.pictureBox1.Size = new System.Drawing.Size(336,
 192);

            this.imageList1.ImageSize = new
 System.Drawing.Size(16, 16);
            this.imageList1.TransparentColor = System.Drawing.Color.Transparent;

            this.panel1.Location = new System.Drawing.Point(8,
 240);
            this.panel1.Size = new System.Drawing.Size(296,
 184);

            this.label5.Location = new System.Drawing.Point(168,
 168);
            this.label5.Size = new System.Drawing.Size(312,
 40);
            this.label5.Text = "label5";

            this.ClientSize = new System.Drawing.Size(672,
 461);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.pictureBox1);
            this.Controls.Add(this.button4);
            this.Controls.Add(this.button3);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.listBox1);
            this.ResumeLayout(false);
        }

        // Display the image.
        private void button1_Click (object
 sender, System.EventArgs e)
        {
            if(imageList1.Images.Empty != true)
            {
                if(imageList1.Images.Count-1 > currentImage)
                {
                    currentImage++;
                }
                else
                {
                    currentImage=0;
                }
                panel1.Refresh();
                
                // Draw the image in the panel.
                imageList1.Draw(myGraphics,10,10,currentImage);

                // Show the image in the PictureBox.
                pictureBox1.Image = imageList1.Images[currentImage];
                label3.Text = "Current image is " + currentImage ;
                listBox1.SelectedIndex = currentImage;
                label5.Text = "Image is " + listBox1.Text ;
            }
        }
 
        // Remove the image.
        private void button2_Click (object
 sender, System.EventArgs e)
        {
            imageList1.Images.RemoveAt(listBox1.SelectedIndex);
            listBox1.Items.Remove(listBox1.SelectedItem);
        }
 
        // Clear all images.
        private void button3_Click (object
 sender, System.EventArgs e)
        {
            imageList1.Images.Clear();
            listBox1.Items.Clear();
        }
 
        // Find an image.
        private void button4_Click (object
 sender, System.EventArgs e)
        {
            openFileDialog1.Multiselect = true ;
            if(openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if (openFileDialog1.FileNames != null)
                {
                    for(int i =0 ; i < openFileDialog1.FileNames.Length
 ; i++ )
                    {
                        addImage(openFileDialog1.FileNames[i]);
                    }
                }
                else
                    addImage(openFileDialog1.FileName);
            }
        }
 
        private void addImage(string
 imageToLoad)
        {
            if (imageToLoad != "")
            {
                imageList1.Images.Add(Image.FromFile(imageToLoad));
                listBox1.BeginUpdate();
                listBox1.Items.Add(imageToLoad);
                listBox1.EndUpdate();
            }
        }
 
        public static void
 Main(string[] args) 
        {
            Application.Run(new Form1());
        }
    }
}
namespace myImageRotator
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
{
    using namespace System;
    using namespace System::Drawing;
    using namespace System::ComponentModel;
    using namespace System::Windows::Forms;

    public ref class Form1 : public
 System::Windows::Forms::Form
    {
    private:
        System::ComponentModel::IContainer^ components;
    private:
        System::Windows::Forms::ListBox^ listBox1;
    private:
        System::Windows::Forms::Label^ label3;
    private:
        System::Windows::Forms::Button^ button1;
    private:
        System::Windows::Forms::Button^ button2;
    private:
        System::Windows::Forms::Button^ button3;
    private:
        System::Windows::Forms::Button^ button4;
    private:
        System::Windows::Forms::PictureBox^ pictureBox1;
    private:
        System::Windows::Forms::ImageList^ imageList1;
    private:
        System::Windows::Forms::OpenFileDialog^ openFileDialog1;
    protected:
        Graphics^ myGraphics;
    private:
        System::Windows::Forms::Panel^ panel1;
    private:
        System::Windows::Forms::Label^ label5;
    private:
        int currentImage;

    public:
        Form1()
        {
            InitializeComponent();
            imageList1 = gcnew ImageList () ;
            currentImage = 0;

            // The default image size is 16 x 16, which sets up a larger
            // image size. 
            imageList1->ImageSize = System::Drawing::Size(255,255);
            imageList1->TransparentColor = Color::White;

            // Assigns the graphics object to use in the draw options.
            myGraphics = Graphics::FromHwnd(panel1->Handle);
        }

    private:
        void InitializeComponent()
        {
            this->components = gcnew System::ComponentModel::Container();
            this->listBox1 = gcnew System::Windows::Forms::ListBox();
            this->label3 = gcnew System::Windows::Forms::Label();
            this->button1 = gcnew System::Windows::Forms::Button();
            this->button2 = gcnew System::Windows::Forms::Button();
            this->button3 = gcnew System::Windows::Forms::Button();
            this->button4 = gcnew System::Windows::Forms::Button();
            this->pictureBox1 = gcnew System::Windows::Forms::PictureBox();
            this->imageList1 = gcnew System::Windows::Forms::ImageList(this->components);
            this->openFileDialog1 = gcnew System::Windows::Forms::OpenFileDialog();
            this->panel1 = gcnew System::Windows::Forms::Panel();
            this->label5 = gcnew System::Windows::Forms::Label();
            this->SuspendLayout();

            this->listBox1->Location = System::Drawing::Point(16,
 16);
            this->listBox1->Size = System::Drawing::Size(400,
 95);
            this->listBox1->TabIndex = 0;

            this->label3->Location = System::Drawing::Point(24,
 168);
            this->label3->Text = "label3";

            this->button1->Location = System::Drawing::Point(96,
 128);
            this->button1->Size = System::Drawing::Size(104,
 23);
            this->button1->Text = "Show Next Image";
            this->button1->Click += gcnew System::EventHandler(this
,&Form1::button1_Click);

            this->button2->Location = System::Drawing::Point(208,
 128);
            this->button2->Size = System::Drawing::Size(104,
 23);
            this->button2->Text = "Remove Image";
            this->button2->Click += gcnew System::EventHandler(this
,&Form1::button2_Click);

            this->button3->Location = System::Drawing::Point(320,
 128);
            this->button3->Text = "Clear List";
            this->button3->Click += gcnew System::EventHandler(this
,&Form1::button3_Click);

            this->button4->Location = System::Drawing::Point(16,
 128);
            this->button4->Text = "Open Image";
            this->button4->Click += gcnew System::EventHandler(this
,&Form1::button4_Click);

            this->pictureBox1->Location = System::Drawing::Point(328,
 232);
            this->pictureBox1->Size = System::Drawing::Size(336,
 192);

            this->imageList1->ImageSize = System::Drawing::Size(16,
 16);
            this->imageList1->TransparentColor = System::Drawing::Color::Transparent;

            this->panel1->Location = System::Drawing::Point(8,
 240);
            this->panel1->Size = System::Drawing::Size(296,
 184);

            this->label5->Location = System::Drawing::Point(168,
 168);
            this->label5->Size = System::Drawing::Size(312,
 40);
            this->label5->Text = "label5";

            this->ClientSize = System::Drawing::Size(672, 461);
            this->Controls->Add(this->label5);
            this->Controls->Add(this->panel1);
            this->Controls->Add(this->pictureBox1);
            this->Controls->Add(this->button4);
            this->Controls->Add(this->button3);
            this->Controls->Add(this->button2);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->label3);
            this->Controls->Add(this->listBox1);
            this->ResumeLayout(false);
        }

        // Display the image.
    private:
        void button1_Click (Object^ /*sender*/, System::EventArgs^
 /*e*/)
        {
            if(imageList1->Images->Empty != true)
            {
                if(imageList1->Images->Count-1 > currentImage)
                {
                    currentImage++;
                }
                else
                {
                    currentImage=0;
                }
                panel1->Refresh();

                // Draw the image in the panel.
                imageList1->Draw(myGraphics,10,10,currentImage);

                // Show the image in the PictureBox.
                pictureBox1->Image = imageList1->Images[currentImage];
                label3->Text = "Current image is " + currentImage ;
                listBox1->SelectedIndex = currentImage;
                //                label5->Text = "Image is "
 + listBox1->Text ;
                label5->Text = String::Concat("Image is ",listBox1->Text);
            }
        }

        // Remove the image.
    private:
        void button2_Click (Object^ /*sender*/, System::EventArgs^
 /*e*/)
        {
            imageList1->Images->RemoveAt(listBox1->SelectedIndex);
            listBox1->Items->Remove(listBox1->SelectedItem);
        }

        // Clear all images.
    private:
        void button3_Click (Object^ /*sender*/, System::EventArgs^
 /*e*/)
        {
            imageList1->Images->Clear();
            listBox1->Items->Clear();
        }

        // Find an image.
    private:
        void button4_Click (Object^ /*sender*/, System::EventArgs^
 /*e*/)
        {
            openFileDialog1->Multiselect = true ;
            if(openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
            {
                if (openFileDialog1->FileNames != nullptr)
                {
                    for(int i =0 ; i < openFileDialog1->FileNames->Length
 ; i++ )
                    {
                        addImage(openFileDialog1->FileNames[i]);
                    }
                }
                else
                    addImage(openFileDialog1->FileName);
            }
        }

    private:
        void addImage(String^ imageToLoad)
        {
            if (imageToLoad != "")
            {
                imageList1->Images->Add(Image::FromFile(imageToLoad));
                listBox1->BeginUpdate();
                listBox1->Items->Add(imageToLoad);
                listBox1->EndUpdate();
            }
        }

    public:
        static void Main(array<String^>^
 /*args*/) 
        {
            Application::Run(gcnew Form1());
        }
    };

}
int main(){
    myImageRotator::Form1::Main(nullptr);
}
package myImageRotator; 

import System.*;
import System.Drawing.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;

public class Form1 extends System.Windows.Forms.Form
{
    protected Container components;
    protected ListBox listBox1;
    protected Label label2;
    protected Label label3;
    protected Label label5;
    protected PictureBox pictureBox1;
    protected Button button1;
    protected Button button2;
    protected Button button3;
    protected Button button4;
    protected Panel panel1;
    protected ImageList imageList1;
    protected Graphics myGraphics;
    protected OpenFileDialog openFileDialog1;
    private int currentImage = 0;

    public Form1()
    {
        InitializeComponent();
        imageList1 = new ImageList();
        // The default image size is 16 x 16, which sets up a larger
        // image size. 
        imageList1.set_ImageSize(new Size(255, 255));
        imageList1.set_TransparentColor(Color.get_White());
        // Assigns the graphics object to use in the draw options.
        myGraphics = Graphics.FromHwnd(panel1.get_Handle());
    } //Form1

    protected void Dispose(boolean disposing)
    {
        if (disposing) {
            if (components != null) {
                components.Dispose();
            }
        }
        super.Dispose(disposing);
    } //Dispose

    private void InitializeComponent()
    {
        // Initializations for listBox1, label2, pictureBox1,
        // button2, button3, panel1, openFileDialog1, button4, label1,
 
        // button1, and imageList1.
    } //InitializeComponent

    protected void button1_Click(Object sender,
 System.EventArgs e)
    {
        DisplayNextImage();
    } //button1_Click

    protected void button2_Click(Object sender,
 System.EventArgs e)
    {
        imageList1.get_Images().RemoveAt(listBox1.get_SelectedIndex());
        listBox1.get_Items().Remove(new Integer(listBox1.
            get_SelectedIndex()));
    } //button2_Click

    protected void button3_Click(Object sender,
 System.EventArgs e)
    {
        imageList1.get_Images().Clear();
    } //button3_Click

    protected void button4_Click(Object sender,
 System.EventArgs e)
    {
        openFileDialog1.set_Multiselect(true);
        if (openFileDialog1.ShowDialog().Equals(get_DialogResult().OK))
 {
            if (openFileDialog1.get_FileNames() != null)
 {
                for (int i = 0; i < openFileDialog1.get_FileNames().length;
                    i++) {
                    AddImage(openFileDialog1.get_FileNames()[i]);
                }
            }
            else {
                AddImage(openFileDialog1.get_FileName());
            }
        }
    } //button4_Click

    private void AddImage(String imageToLoad)
    {
        if (!(imageToLoad.Equals(""))) {
            imageList1.get_Images().Add(Image.FromFile(imageToLoad));
            listBox1.BeginUpdate();
            listBox1.get_Items().Add(imageToLoad);
            listBox1.EndUpdate();
        }
    } //AddImage

    void DisplayNextImage()
    {
        if (imageList1.get_Images().get_Empty() != true)
 {
            if (imageList1.get_Images().get_Count() - 1 < currentImage)
 {
                currentImage++;
            }
            else {
                currentImage = 0;
            }
            panel1.Refresh();
            imageList1.Draw(myGraphics, 10, 10, currentImage);
            pictureBox1.set_Image(imageList1.get_Images().
                get_Item(currentImage));
            label3.set_Text("Current image is " + currentImage);
            listBox1.set_SelectedIndex(currentImage);
            label5.set_Text("Image is " + listBox1.get_Text());
        }
    } //DisplayNextImage

    public static void main(String[]
 args)
    {
        Application.Run(new Form1());
    } //main
} //Form1
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
      System.Windows.Forms.ImageList
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ImageList コンストラクタ ()

ImageList クラス新しインスタンスColorDepthImageSize、および TransparentColor の既定値初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説

ImageListインスタンス初期プロパティ値を次の表に示します

項目

説明

ColorDepth

既定値は Depth4Bit です。

ImageSize

既定値は、高さ 16、幅 16Size オブジェクトです。

TransparentColor

既定値Transparent です。

使用例使用例

ImageList構築しImages プロパティイメージ追加しImageSize プロパティ設定してDraw メソッド使用するコード例次に示します。この例を実行するには、Button1 という名前のボタン配置されフォーム中にこの例を配置します。この例では、c:\Windows\ に FeatherTexture.bmp および Gone Fishing.bmp置かれていることを前提としています。これらのビットマップシステム存在しない場合、または他の場所存在する場合は、必要に応じて例を変更してください

Friend WithEvents ImageList1 As
 System.Windows.Forms.ImageList

' Create an ImageList Object, populate it, and display
' the images it contains.
Private Sub Button1_Click(ByVal
 sender As System.Object, _
    ByVal e As System.EventArgs) Handles
 Button1.Click

    ' Construct the ImageList.
    ImageList1 = New ImageList

    ' Set the ImageSize property to a larger size 
    ' (the default is 16 x 16).
    ImageList1.ImageSize = New Size(112, 112)

    ' Add two images to the list.
    ImageList1.Images.Add(Image.FromFile _
        ("c:\windows\FeatherTexture.bmp"))
    ImageList1.Images.Add _
        (Image.FromFile("C:\windows\Gone Fishing.bmp"))

    Dim count As System.Int32

    ' Get a Graphics object from the form's handle.
    Dim theGraphics As Graphics = Graphics.FromHwnd(Me.Handle)

    ' Loop through the images in the list, drawing each image.
    For count = 0 To ImageList1.Images.Count
 - 1
        ImageList1.Draw(theGraphics, New Point(85, 85), count)

        ' Call Application.DoEvents to force a repaint of the form.
        Application.DoEvents()

        ' Call the Sleep method to allow the user to see the image.
        System.Threading.Thread.Sleep(1000)
    Next
End Sub

internal System.Windows.Forms.ImageList ImageList1;

// Create an ImageList Object, populate it, and display
// the images it contains.
private void Button1_Click(System.Object sender,
 
    System.EventArgs e)
{

    // Construct the ImageList.
    ImageList1 = new ImageList();

    // Set the ImageSize property to a larger size 
    // (the default is 16 x 16).
    ImageList1.ImageSize = new Size(112, 112);

    // Add two images to the list.
    ImageList1.Images.Add(
        Image.FromFile("c:\\windows\\FeatherTexture.bmp"));
    ImageList1.Images.Add(
        Image.FromFile("C:\\windows\\Gone Fishing.bmp"));

    // Get a Graphics object from the form's handle.
    Graphics theGraphics = Graphics.FromHwnd(this.Handle);

    // Loop through the images in the list, drawing each image.
    for(int count = 0; count < ImageList1.Images.Count;
 count++)
    {
        ImageList1.Draw(theGraphics, new Point(85, 85), count);

        // Call Application.DoEvents to force a repaint of the form.
        Application.DoEvents();

        // Call the Sleep method to allow the user to see the image.
        System.Threading.Thread.Sleep(1000);
    }
}

internal:
   System::Windows::Forms::ImageList^ ImageList1;

private:

   // Create an ImageList Object, populate it, and display
   // the images it contains.
   void Button1_Click( System::Object^ /*sender*/, System::EventArgs^
 /*e*/ )
   {
      
      // Construct the ImageList.
      ImageList1 = gcnew ImageList;
      
      // Set the ImageSize property to a larger size 
      // (the default is 16 x 16).
      ImageList1->ImageSize = System::Drawing::Size( 112, 112 );
      
      // Add two images to the list.
      ImageList1->Images->Add( Image::FromFile( "c:\\windows\\FeatherTexture.bmp"
 ) );
      ImageList1->Images->Add( Image::FromFile( "C:\\windows\\Gone Fishing.bmp"
 ) );
      
      // Get a Graphics object from the form's handle.
      Graphics^ theGraphics = Graphics::FromHwnd( this->Handle
 );
      
      // Loop through the images in the list, drawing each image.
      for ( int count = 0; count < ImageList1->Images->Count;
 count++ )
      {
         ImageList1->Draw( theGraphics, Point(85,85), count );
         
         // Call Application.DoEvents to force a repaint of the form.
         Application::DoEvents();
         
         // Call the Sleep method to allow the user to see the image.
         System::Threading::Thread::Sleep( 1000 );

      }
   }
private System.Windows.Forms.ImageList imageList1;

// Create an ImageList Object, populate it, and display
// the images it contains.
private void button1_Click(Object sender, System.EventArgs
 e)
{
    // Construct the ImageList.
    imageList1 = new ImageList();
    // Set the ImageSize property to a larger size 
    // (the default is 16 x 16).
    imageList1.set_ImageSize(new Size(112, 112));
    // Add two images to the list.
    imageList1.get_Images().Add(Image.FromFile(
        "c:\\windows\\FeatherTexture.bmp"));
    imageList1.get_Images().Add(Image.FromFile(
        "C:\\windows\\Gone Fishing.bmp"));
    // Get a Graphics object from the form's handle.
    Graphics theGraphics = Graphics.FromHwnd(this.get_Handle());
    // Loop through the images in the list, drawing each image.
    for (int count = 0; count < imageList1.get_Images().get_Count();
 
        count++) {
        imageList1.Draw(theGraphics, new Point(85, 85), count);
        // Call Application.DoEvents to force a repaint of the form.
        Application.DoEvents();
        // Call the Sleep method to allow the user to see the image.
        System.Threading.Thread.Sleep(1000);
    }
} //button1_Click
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ImageList コンストラクタ (IContainer)

コンテナ関連付けて、ImageList クラス新しインスタンス初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Sub New ( _
    container As IContainer _
)
public ImageList (
    IContainer container
)
public:
ImageList (
    IContainer^ container
)
public ImageList (
    IContainer container
)
public function ImageList (
    container : IContainer
)

パラメータ

container

ImageList のこのインスタンス関連付ける、IContainer を実装するオブジェクト

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ImageList コンストラクタ


ImageList プロパティ


ImageList メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド CreateObjRef  リモート オブジェクトとの通信使用するプロキシ生成必要な情報をすべて格納しているオブジェクト作成します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド Dispose  オーバーロードされますComponent によって使用されているリソース解放します。 ( Component から継承されます。)
パブリック メソッド Draw オーバーロードされます示されイメージ描画ます。
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetLifetimeService  対象インスタンス有効期間ポリシー制御する現在の有効期間サービス オブジェクト取得します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド InitializeLifetimeService  対象インスタンス有効期間ポリシー制御する有効期間サービス オブジェクト取得します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド ToString オーバーライドされます現在の ImageList を表す文字列を返します
プロテクト メソッドプロテクト メソッド
参照参照

ImageList メンバ

Image オブジェクトコレクション管理するメソッド提供します。このクラス継承できません。

ImageList データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
パブリック プロパティパブリック プロパティ
プロテクト プロパティプロテクト プロパティ
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド CreateObjRef  リモート オブジェクトとの通信使用するプロキシ生成必要な情報をすべて格納しているオブジェクト作成します。 (MarshalByRefObject から継承されます。)
パブリック メソッド Dispose  オーバーロードされますComponent によって使用されているリソース解放します。 (Component から継承されます。)
パブリック メソッド Draw オーバーロードされます示されイメージ描画ます。
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetLifetimeService  対象インスタンス有効期間ポリシー制御する現在の有効期間サービス オブジェクト取得します。 (MarshalByRefObject から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド InitializeLifetimeService  対象インスタンス有効期間ポリシー制御する有効期間サービス オブジェクト取得します。 (MarshalByRefObject から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド ToString オーバーライドされます現在の ImageList を表す文字列を返します
プロテクト メソッドプロテクト メソッド
パブリック イベントパブリック イベント
参照参照

Imagelist

出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2022/08/30 17:08 UTC 版)




英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Imagelist」の関連用語

Imagelistのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Imagelistのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.
ウィキペディアウィキペディア
All text is available under the terms of the GNU Free Documentation License.
この記事は、ウィキペディアのImagelist (改訂履歴)の記事を複製、再配布したものにあたり、GNU Free Documentation Licenseというライセンスの下で提供されています。 Weblio辞書に掲載されているウィキペディアの記事も、全てGNU Free Documentation Licenseの元に提供されております。

©2024 GRAS Group, Inc.RSS