ImageList Konstruktorów
Definicja
Ważny
Niektóre informacje dotyczą produktów przedpremierowych, które mogą zostać znacznie zmodyfikowane przed premierą. Microsoft nie udziela żadnych gwarancji, ani wyraźnych, ani domniemanych, dotyczących informacji podanych tutaj.
Inicjuje nowe wystąpienie klasy ImageList.
Przeciążenia
| Nazwa | Opis |
|---|---|
| ImageList() |
Inicjuje ImageList nowe wystąpienie klasy z wartościami domyślnymi dla ColorDepth, ImageSizei TransparentColor. |
| ImageList(IContainer) |
Inicjuje ImageList nowe wystąpienie klasy, kojarząc je z kontenerem. |
ImageList()
- Źródło:
- ImageList.cs
- Źródło:
- ImageList.cs
- Źródło:
- ImageList.cs
- Źródło:
- ImageList.cs
- Źródło:
- ImageList.cs
Inicjuje ImageList nowe wystąpienie klasy z wartościami domyślnymi dla ColorDepth, ImageSizei TransparentColor.
public:
ImageList();
public ImageList();
Public Sub New ()
Przykłady
W poniższym przykładzie kodu pokazano konstruowanie ImageListobiektu , dodawanie obrazów do Images właściwości, ustawianie ImageSize właściwości i używanie Draw metody . Aby uruchomić ten przykład, umieść go w formularzu zawierającym przycisk o nazwie Button1. W przykładzie przyjęto założenie istnienia FeatherTexture.bmp obiektów i Gone Fishing.bmp w c:\Windows\. Zmień przykład odpowiednio, jeśli mapy bitowe nie istnieją w systemie lub istnieją w innej lokalizacji.
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
Uwagi
W poniższej tabeli przedstawiono początkowe wartości właściwości dla wystąpienia klasy ImageList.
| Element | Opis |
|---|---|
| ColorDepth | W wersjach .NET Framework i .NET (Core) za pośrednictwem platformy .NET 7 wartość domyślna to Depth8Bit. W programie .NET 8 i nowszych wersjach wartość domyślna to Depth32Bit. |
| ImageSize | Wartość domyślna Size to obiekt o wysokości i szerokości 16 do 16. |
| TransparentColor | Wartość domyślna to Transparent. |
Dotyczy
ImageList(IContainer)
- Źródło:
- ImageList.cs
- Źródło:
- ImageList.cs
- Źródło:
- ImageList.cs
- Źródło:
- ImageList.cs
- Źródło:
- ImageList.cs
Inicjuje ImageList nowe wystąpienie klasy, kojarząc je z kontenerem.
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)
Parametry
- container
- IContainer
Obiekt implementowania IContainer w celu skojarzenia z tym wystąpieniem klasy ImageList.
Uwagi
Konstruktor ImageList umożliwia skojarzenie obiektu z dowolnym Container obiektemImageList. Kojarząc ten typ ImageList , należy przekazać kontrolę nad okresem istnienia ImageList obiektu do obiektu Container. Może to być przydatne, jeśli używasz wielu składników w aplikacji i chcesz usunąć wszystkie z nich jednocześnie. Jeśli na przykład skojarzysz ToolTipelement , i ImageListTimer z elementem Container, wywołanie Dispose metody w kontenerze wymusi również usunięcie wszystkich tych składników.