ImageList.ImageSize 속성

정의

이미지 목록에 있는 이미지의 크기를 가져오거나 설정합니다.

public:
 property System::Drawing::Size ImageSize { System::Drawing::Size get(); void set(System::Drawing::Size value); };
public System.Drawing.Size ImageSize { get; set; }
member this.ImageSize : System.Drawing.Size with get, set
Public Property ImageSize As Size

속성 값

Size

목록에 있는 이미지의 높이와 너비를 픽셀 단위로 정의하는 Size입니다. 기본 크기는 16x16이고 최대 크기는 256x256입니다.

예외

할당된 값이 IsEmpty와 같은 경우

또는 높이 또는 너비 값이 0보다 작거나 같은 경우

또는 높이 또는 너비 값이 256보다 큰 경우

새 크기 값이 0보다 작거나 256보다 큰 경우

예제

다음 코드 예제에서는 생성 하는 방법을 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

설명

이미지 컬렉션에 ImageSize 이미지를 추가하기 전에 속성을 설정하면 지정된 이미지 크기로 이미지 크기가 조정됩니다.

속성을 새 값 Handle 으로 설정 ImageSize 하면 이미지 목록이 다시 만들어집니다.

속성을 설정하면 ImageSize 핸들이 다시 만들어지므로 속성을 설정 Images 하기 전에 설정 ImageSize 해야 합니다. 핸들이 ImageList 만들어지면 코드를 설정하거나 ImageSize 속성을 설정 ColorDepth Images 하면 속성에 설정된 이미지 컬렉션이 Images 삭제됩니다.

적용 대상