Freigeben über


Label.Image-Eigenschaft

Ruft das in Label dargestellte Bild ab oder legt dieses fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
<LocalizableAttribute(True)> _
Public Property Image As Image
'Usage
Dim instance As Label
Dim value As Image

value = instance.Image

instance.Image = value
[LocalizableAttribute(true)] 
public Image Image { get; set; }
[LocalizableAttribute(true)] 
public:
property Image^ Image {
    Image^ get ();
    void set (Image^ value);
}
/** @property */
public Image get_Image ()

/** @property */
public void set_Image (Image value)
public function get Image () : Image

public function set Image (value : Image)

Eigenschaftenwert

Ein Image, das im Label dargestellt wird. Der Standardwert ist NULL (Nothing in Visual Basic).

Hinweise

Die Image-Eigenschaft kann nicht gleichzeitig mit der ImageList-Eigenschaft und der ImageIndex-Eigenschaft verwendet werden. Wenn die Image-Eigenschaft zur Darstellung eines Bilds verwendet wird, werden die ImageList-Eigenschaft und die ImageIndex-Eigenschaft automatisch auf ihre Standardeinstellungen zurückgesetzt.

Beispiel

Im folgenden Codebeispiel wird das Erstellen eines Label und anschließend das Anzeigen eines Image im Hintergrund des Label veranschaulicht. Zunächst wird ein Label und dann ein Image aus einer Datei auf dem Datenträger erstellt. Anschließend wird die Size-Eigenschaft initialisiert, sodass das Image enthalten ist. Schließlich wird die Image-Eigenschaft auf das Image-Objekt initialisiert.

Private Sub CreateMyLabel()

    ' Create a new label and bitmap.

    Dim Label1 As New Label()
    Dim Image1 As Image

    Image1 = Image.FromFile("c:\\MyImage.bmp")
   

    ' Set the size of the label to accommodate the bitmap size.

    Label1.Size = Image1.Size        

    ' Initialize the label control's Image property.

    Label1.Image = Image1

    ' ...Code to add the control to the form...

End Sub
public void CreateMyLabel() 
{
 
    // Create a new label and create a bitmap.

    Label label1 = new Label();
    Image image1 = Image.FromFile("c:\\MyImage.bmp");

    // Set the size of the label to accommodate the bitmap size.

    label1.Size = new Size(image1.Width, image1.Height);

    // Initialize the label control's Image property.

    label1.Image = image1;

    // ...Code to add the control to the form...

}
public:
   void CreateMyLabel()
   {
      // Create a new label and create a bitmap.
      Label^ label1 = gcnew Label;
      Image^ image1 = Image::FromFile( "c:\\MyImage.bmp" );

      // Set the size of the label to accommodate the bitmap size.
      label1->Size = System::Drawing::Size( image1->Width, image1->Height );

      // Initialize the label control's Image property.
      label1->Image = image1;

      // ...Code to add the control to the form...
   }
public void CreateMyLabel()
{
    // Create a new label and create a bitmap.
    Label label1 = new Label();
    Image image1 = Image.FromFile("c:\\MyImage.bmp");

    // Set the size of the label to accommodate the bitmap size.
    label1.set_Size(new Size(image1.get_Width(), image1.get_Height()));

    // Initialize the label control's Image property.
    label1.set_Image(image1);
} //CreateMyLabel
// ...Code to add the control to the form...

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Label-Klasse
Label-Member
System.Windows.Forms-Namespace
Image
ImageAlign
ImageList
ImageIndex