다음을 통해 공유


ImageList.ImageSize 속성

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

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
<LocalizableAttribute(True)> _
Public Property ImageSize As Size
‘사용 방법
Dim instance As ImageList
Dim value As Size

value = instance.ImageSize

instance.ImageSize = value
[LocalizableAttribute(true)] 
public Size ImageSize { get; set; }
[LocalizableAttribute(true)] 
public:
property Size ImageSize {
    Size get ();
    void set (Size value);
}
/** @property */
public Size get_ImageSize ()

/** @property */
public void set_ImageSize (Size value)
public function get ImageSize () : Size

public function set ImageSize (value : Size)

속성 값

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

예외

예외 형식 조건

ArgumentException

할당된 값이 IsEmpty와 같은 경우

- 또는 -

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

- 또는 -

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

ArgumentOutOfRangeException

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

설명

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

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

ImageSize 속성을 설정하면 핸들이 다시 만들어지므로 Images 속성을 설정하기 전에 ImageSize를 먼저 설정해야 합니다. Images 속성을 설정한 다음 코드에서 ColorDepth 또는 ImageSize 속성을 설정하면 Images 속성에 대해 설정된 이미지의 컬렉션이 삭제됩니다.

예제

다음 코드 예제에서는 ImageList를 생성하고 Images 속성에 이미지를 추가한 다음 ImageSize 속성을 설정하고 Draw 메서드를 사용하는 방법을 보여 줍니다. 이 예제를 실행하려면 Button1이라는 단추가 포함된 폼에 다음 코드를 붙여넣습니다. 이 예제에서는 FeatherTexture.bmpGone Fishing.bmp가 c:\\Windows\에 있다고 가정합니다. 이 비트맵이 시스템에 없거나 다른 위치에 있으면 예제를 적절하게 변경합니다.

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

      }
   }
private System.Windows.Forms.ImageList imageList1;

// Create an ImageList Object, populate it, and display
// the images it contains.
private void button1_Click(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.set_ImageSize(new Size(112, 112));
    // Add two images to the list.
    imageList1.get_Images().Add(Image.FromFile(
        "c:\\windows\\FeatherTexture.bmp"));
    imageList1.get_Images().Add(Image.FromFile(
        "C:\\windows\\Gone Fishing.bmp"));
    // Get a Graphics object from the form's handle.
    Graphics theGraphics = Graphics.FromHwnd(this.get_Handle());
    // Loop through the images in the list, drawing each image.
    for (int count = 0; count < imageList1.get_Images().get_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);
    }
} //button1_Click

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

ImageList 클래스
ImageList 멤버
System.Windows.Forms 네임스페이스