次の方法で共有


ImageList コンストラクター

定義

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

オーバーロード

名前 説明
ImageList()

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

ImageList(IContainer)

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

ImageList()

ソース:
ImageList.cs
ソース:
ImageList.cs
ソース:
ImageList.cs
ソース:
ImageList.cs
ソース:
ImageList.cs

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

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

次のコード例では、 ImageListの構築、 Images プロパティへのイメージの追加、 ImageSize プロパティの設定、 Draw メソッドの使用を示します。 この例を実行するには、 Button1という名前のボタンを含むフォームに配置します。 この例では、c:\Windows\ に FeatherTexture.bmpGone Fishing.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のインスタンスの初期プロパティ値を示します。

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

適用対象

ImageList(IContainer)

ソース:
ImageList.cs
ソース:
ImageList.cs
ソース:
ImageList.cs
ソース:
ImageList.cs
ソース:
ImageList.cs

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

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

注釈

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

適用対象