ImageList.ImageSize Tulajdonság
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Lekéri vagy beállítja a képek méretét a képlistában.
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
Tulajdonság értéke
Ez Size határozza meg a listában szereplő képek magasságát és szélességét képpontban. Az alapértelmezett méret 16–16. A maximális méret 256 és 256 között van.
Kivételek
A hozzárendelt érték egyenlő .IsEmpty
-vagy-
A magasság vagy szélesség értéke kisebb vagy egyenlő 0-nál.
-vagy-
A magasság vagy szélesség értéke nagyobb, mint 256.
Az új méret mérete kisebb, mint 0 vagy nagyobb, mint 256.
Példák
Az alábbi példakód bemutatja, hogy egy ImageListrendszerképet kell hozzáadni a Images tulajdonsághoz, beállítani a ImageSize tulajdonságot, és használni a metódust Draw . A példa futtatásához helyezze el egy gombot Button1tartalmazó űrlapon. A példa feltételezi a FeatherTexture.bmp és Gone Fishing.bmp meglétét a c:\Windows\ helyen. Ennek megfelelően módosítsa a példát, ha a bittérképek nem léteznek a rendszeren, vagy más helyen vannak.
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
Megjegyzések
Ha a tulajdonságot a ImageSize képgyűjteményhez való felvétel előtt állítja be, a rendszer a képeket a megadott képméretre méretezi át.
Amikor a ImageSize tulajdonságot új értékre állítja, a Handle rendszer újra létrehozza a képlistát.
Mivel a ImageSize tulajdonság beállítása miatt a leíró újra létrejön, a tulajdonság beállítása előtt be kell állítania ImageSizeImages. A leíró ImageList létrehozásakor a tulajdonság beállítása ColorDepth után a ImageSize kódban megadott tulajdonságok vagy Images tulajdonságok a tulajdonsághoz Images beállított képek gyűjteményének törlését okozzák.