다음을 통해 공유


ImageList 생성자

정의

ImageList 클래스의 새 인스턴스를 초기화합니다.

오버로드

Name Description
ImageList()

및 에 대한 기본값을 ImageList 사용하여 클래스의 새 인스턴스를 ColorDepthImageSizeTransparentColor초기화합니다.

ImageList(IContainer)

클래스의 새 인스턴스를 ImageList 초기화하여 컨테이너와 연결합니다.

ImageList()

Source:
ImageList.cs
Source:
ImageList.cs
Source:
ImageList.cs
Source:
ImageList.cs
Source:
ImageList.cs

및 에 대한 기본값을 ImageList 사용하여 클래스의 새 인스턴스를 ColorDepthImageSizeTransparentColor초기화합니다.

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

예제

다음 코드 예제에서는 생성 하는 방법을 ImageList보여 줍니다., 속성에 Images 이미지를 추가, 속성을 설정 ImageSize 하 고 메서드를 Draw 사용 하 여 합니다. 이 예제를 실행하려면 이름이 인 Button1단추가 포함된 폼에 배치합니다. 이 예제에서는 c:\Windows\의 FeatherTexture.bmp 존재 여부에 Gone 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.

Item 설명
ColorDepth .NET 7을 통한 .NET Framework 및 .NET(Core) 버전에서 기본값은 .NET입니다 Depth8Bit. .NET 8 이상 버전에서 기본값은 .NET 8 이상 버전입니다 Depth32Bit.
ImageSize 기본값은 Size 높이와 너비가 16 x 16인 개체입니다.
TransparentColor 기본값은 Transparent입니다.

적용 대상

ImageList(IContainer)

Source:
ImageList.cs
Source:
ImageList.cs
Source:
ImageList.cs
Source:
ImageList.cs
Source:
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

이 인스턴스와 연결할 개체 IContainer 입니다 ImageList.

설명

ImageList 생성자를 사용하면 개체와 연결할 ImageList 수 있습니다Container. 이와 같이 연결하면 ImageList 수명을 ImageList 제어할 수 Container있습니다. 이는 애플리케이션에서 여러 구성 요소를 사용하고 동시에 모든 구성 요소를 삭제하려는 경우에 유용할 수 있습니다. 예를 들어 컨테이너에서 ToolTip호출 Dispose 하는 경우 , 및 ImageLista TimerContainer를 연결하면 이러한 모든 구성 요소도 강제로 삭제됩니다.

적용 대상