ImageList.ImageSize ImageList.ImageSize ImageList.ImageSize ImageList.ImageSize Property

정의

이미지 목록의 이미지의 크기를 가져오거나 설정 합니다.Gets or sets the size of the images in the image list.

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 높이 너비를 픽셀의 이미지 목록에 대해 정의 하는 합니다.The Size that defines the height and width, in pixels, of the images in the list. 기본 크기는 16x16 합니다.The default size is 16 by 16. 최대 크기는 256x256입니다.The maximum size is 256 by 256.

예외

할당 된 값이 같지 IsEmpty합니다.The value assigned is equal to IsEmpty.

또는-or- 높이 또는 너비 값이 0 보다 작거나 경우The value of the height or width is less than or equal to 0.

또는-or- 높이 또는 너비 값이 256 보다 큽니다.The value of the height or width is greater than 256.

새 크기 보다 작거나 0 보다 크고 256 차원을 있습니다.The new size has a dimension less than 0 or greater than 256.

예제

다음 코드 예제를 생성 하는 방법을 보여 줍니다는 ImageList, 이미지를 추가 합니다 Images 속성을 설정 합니다 ImageSize 속성을 사용 하 여를 Draw 메서드.The following code example demonstrates constructing an ImageList, adding images to the Images property, setting the ImageSize property, and using the Draw method. 이 예제를 실행 하려면 라는 단추가 포함 된 폼에 배치 Button1합니다.To run this example, place it in a form containing a button named Button1. 이 예제에서는 있다고 가정 FeatherTexture.bmp 하 고 Gone Fishing.bmp c:\Windows에\입니다.The example assumes the existence of FeatherTexture.bmp and Gone Fishing.bmp at c:\Windows\. 비트맵에 시스템에 존재 하지 않거나 다른 위치에 존재 하는 경우에 예제를 적절 하 게 변경 합니다.Change the example accordingly if the bitmaps do not exist on your system, or exist at another location.

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 이미지 컬렉션에 이미지를 추가 하기 전에 속성으로 인해 이미지를 지정 된 이미지 크기를 조정할 수 있습니다.Setting the ImageSize property prior to adding images to the image collection causes the images to be resized to the image size specified.

설정한 경우 합니다 ImageSize 속성을 새 값을 Handle 이미지 목록을 다시 생성 됩니다.When you set the ImageSize property to a new value, the Handle for the image list is recreated.

설정 이기 때문에 합니다 ImageSize 속성으로 인해 핸들이 다시 설정 해야 합니다 ImageSize 설정 하기 전에 Images 속성입니다.Because setting the ImageSize property causes the handle to be recreated, you should set ImageSize prior to setting the Images property. 경우에 대 한 핸들을 ImageList 생성 설정를 ColorDepth 또는 ImageSize 속성을 설정한 후 코드에는 Images 속성을 설정 하는 이미지의 컬렉션 하면는 Images 속성을 삭제할 수.When the handle for the ImageList has been created, setting the ColorDepth or ImageSize properties in code, after setting the Images property, will cause the collection of images set for the Images property to be deleted.

적용 대상