ImageList Konstruktorok
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.
Inicializálja a ImageList osztály új példányát.
Túlterhelések
| Name | Description |
|---|---|
| ImageList() |
Inicializálja az osztály új példányát az ImageList , ColorDepthés ImageSizeaz alapértelmezett értékekkelTransparentColor. |
| ImageList(IContainer) |
Inicializálja az ImageList osztály új példányát, és társítja azt egy tárolóval. |
ImageList()
- Forrás:
- ImageList.cs
- Forrás:
- ImageList.cs
- Forrás:
- ImageList.cs
- Forrás:
- ImageList.cs
- Forrás:
- ImageList.cs
Inicializálja az osztály új példányát az ImageList , ColorDepthés ImageSizeaz alapértelmezett értékekkelTransparentColor.
public:
ImageList();
public ImageList();
Public Sub New ()
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
Az alábbi táblázat a példány kezdeti tulajdonságértékét ImageListmutatja be.
| Termék | Leírás |
|---|---|
| ColorDepth | .NET Framework és .NET (Core) verziókban a 7-.NET az alapértelmezett érték a Depth8Bit. A 8-.NET és újabb verziókban az alapértelmezett érték a Depth32Bit. |
| ImageSize | Az alapértelmezett érték egy Size olyan objektum, amelynek magassága és szélessége 16 és 16 között van. |
| TransparentColor | Az alapértelmezett érték a Transparent. |
A következőre érvényes:
ImageList(IContainer)
- Forrás:
- ImageList.cs
- Forrás:
- ImageList.cs
- Forrás:
- ImageList.cs
- Forrás:
- ImageList.cs
- Forrás:
- ImageList.cs
Inicializálja az ImageList osztály új példányát, és társítja azt egy tárolóval.
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)
Paraméterek
- container
- IContainer
A példányhoz IContainertársítandó objektumImageList.
Megjegyzések
A ImageList konstruktor segítségével bármilyen ImageList objektumhoz társíthat egy objektumotContainer. A hasonlók társításával ImageList adod át az irányítást az élettartam felett a ImageListContainer. Ez akkor lehet hasznos, ha számos összetevőt használ az alkalmazásban, és egyszerre szeretné megsemmisíteni az összes összetevőt. Ha például egy ToolTip, egy ImageListés egy Timer elemet társít a Containertárolóhoz, Dispose az összes összetevő eltávolítását is kikényszeríteni fogja.