Freigeben über


ImageList Konstruktoren

Definition

Initialisiert eine neue Instanz der ImageList-Klasse.

Überlädt

Name Beschreibung
ImageList()

Initialisiert eine neue Instanz der ImageList Klasse mit Standardwerten für ColorDepth, ImageSizeund TransparentColor.

ImageList(IContainer)

Initialisiert eine neue Instanz der ImageList Klasse, die sie einem Container zuordnet.

ImageList()

Quelle:
ImageList.cs
Quelle:
ImageList.cs
Quelle:
ImageList.cs
Quelle:
ImageList.cs
Quelle:
ImageList.cs

Initialisiert eine neue Instanz der ImageList Klasse mit Standardwerten für ColorDepth, ImageSizeund TransparentColor.

public:
 ImageList();
public ImageList();
Public Sub New ()

Beispiele

Im folgenden Codebeispiel wird das Erstellen einer , das Hinzufügen von ImageListBildern zur Images Eigenschaft, das Festlegen der ImageSize Eigenschaft und die Verwendung der Draw Methode veranschaulicht. Wenn Sie dieses Beispiel ausführen möchten, platzieren Sie es in einem Formular, das eine Schaltfläche mit dem Namen enthält Button1. Im Beispiel wird davon ausgegangen, dass c:\Windows\vorhanden FeatherTexture.bmp ist.Gone Fishing.bmp Ändern Sie das Beispiel entsprechend, wenn die Bitmaps nicht auf Ihrem System vorhanden sind oder an einem anderen Speicherort vorhanden sind.

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

Hinweise

In der folgenden Tabelle sind die anfänglichen Eigenschaftswerte für eine Instanz von ImageList.

Element Beschreibung
ColorDepth In .NET Framework- und .NET-Versionen (Core) über .NET 7 ist Depth8Bitder Standardwert . In .NET 8 und höheren Versionen ist Depth32Bitder Standardwert .
ImageSize Der Standardwert ist ein Size Objekt mit einer Höhe und Breite von 16 x 16.
TransparentColor Der Standardwert ist Transparent.

Gilt für:

ImageList(IContainer)

Quelle:
ImageList.cs
Quelle:
ImageList.cs
Quelle:
ImageList.cs
Quelle:
ImageList.cs
Quelle:
ImageList.cs

Initialisiert eine neue Instanz der ImageList Klasse, die sie einem Container zuordnet.

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)

Parameter

container
IContainer

Ein Objekt IContainer , das implementiert wird, das dieser Instanz von ImageList.

Hinweise

Mit dem ImageList Konstruktor können Sie ein ImageList beliebiges Container Objekt zuordnen. Indem Sie dies ImageList wie folgt zuordnen, übergeben Sie die Kontrolle über die Lebensdauer der ImageList an die Container. Dies kann nützlich sein, wenn Sie eine Reihe von Komponenten in Ihrer Anwendung verwenden und alle gleichzeitig löschen möchten. Wenn Sie z. B. eine ToolTip, eine ImageListund eine Timer mit einem Container, dem Aufruf Dispose des Containers verknüpfen, erzwingt auch die Entsorgung aller dieser Komponenten.

Gilt für: