ImageList コンストラクター

定義

ImageList クラスの新しいインスタンスを初期化します。

オーバーロード

ImageList()

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

ImageList(IContainer)

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

ImageList()

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

public:
 ImageList();
public ImageList ();
Public Sub New ()

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

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

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

注釈

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

Item 説明
ColorDepth .NET Framework および .NET (Core) バージョンから .NET 7 までのバージョンでは、既定値は ですDepth8Bit。 .NET 8 以降のバージョンでは、既定値は です Depth32Bit
ImageSize 既定値は、 Size 高さと幅が 16 ~ 16 のオブジェクトです。
TransparentColor 既定値は Transparent です。

適用対象

ImageList(IContainer)

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

public:
 ImageList(System::ComponentModel::IContainer ^ container);
public ImageList (System.ComponentModel.IContainer container);
new System.Windows.Forms.ImageList : System.ComponentModel.IContainer -> System.Windows.Forms.ImageList
Public Sub New (container As IContainer)

パラメーター

container
IContainer

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

注釈

ImageListコンストラクターを使用すると、 を任意ContainerImageListオブジェクトに関連付けることができます。 このような を ImageList 関連付けることで、 の有効期間 ImageList の制御を に渡します Container。 これは、アプリケーションで多数のコンポーネントを使用し、それらのすべてを同時に破棄する場合に便利です。 たとえば、 、、 ImageListContainerTimer に関連付けたToolTip場合、 コンテナーで を呼び出すとDispose、これらのコンポーネントもすべて強制的に破棄されます。

適用対象