Freigeben über


ButtonBase.Image-Eigenschaft

Ruft das auf einem Schaltflächen-Steuerelement angezeigte 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 ButtonBase
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

Das Image, das auf dem Schaltflächen-Steuerelement angezeigt wird. Der Standardwert ist NULL (Nothing in Visual Basic).

Hinweise

Wenn die Image-Eigenschaft festgelegt ist, wird die ImageList-Eigenschaft auf NULL (Nothing in Visual Basic) und die ImageIndex-Eigenschaft auf den Standardwert -1 festgelegt.

Hinweis

Wenn die FlatStyle-Eigenschaft auf FlatStyle.System festgelegt ist, werden der Image-Eigenschaft zugewiesene Bilder nicht angezeigt.

Beispiel

Im folgenden Codebeispiel wird die abgeleitete Klasse Button verwendet, und einige ihrer allgemeinen Eigenschaften werden festgelegt. Das Ergebnis ist eine flache Schaltfläche mit Text auf der linken und einem Bild auf der rechten Seite. Für diesen Code ist es erforderlich, dass im Verzeichnis C:\Graphics eine Bitmap mit dem Namen MyBitMap.bmp gespeichert wurde und ein Verweis auf den System.Drawing-Namespace enthalten ist.

Private Sub SetMyButtonProperties()
    ' Assign an image to the button.
    button1.Image = Image.FromFile("C:\Graphics\MyBitmap.bmp")
    ' Align the image and text on the button.
    button1.ImageAlign = ContentAlignment.MiddleRight
    button1.TextAlign = ContentAlignment.MiddleLeft
    ' Give the button a flat appearance.
    button1.FlatStyle = FlatStyle.Flat
End Sub 'SetMyButtonProperties
private void SetMyButtonProperties()
 {
    // Assign an image to the button.
    button1.Image = Image.FromFile("C:\\Graphics\\MyBitmap.bmp");
    // Align the image and text on the button.
    button1.ImageAlign = ContentAlignment.MiddleRight;    
    button1.TextAlign = ContentAlignment.MiddleLeft;
    // Give the button a flat appearance.
    button1.FlatStyle = FlatStyle.Flat;
 }
 
private:
   void SetMyButtonProperties()
   {
      // Assign an image to the button.
      button1->Image = Image::FromFile( "C:\\Graphics\\MyBitmap.bmp" );
      // Align the image and text on the button.
      button1->ImageAlign = ContentAlignment::MiddleRight;
      button1->TextAlign = ContentAlignment::MiddleLeft;
      // Give the button a flat appearance.
      button1->FlatStyle = FlatStyle::Flat;
   }
private void SetMyButtonProperties()
{
    // Assign an image to the button.
    button1.set_Image(Image.FromFile("C:\\Graphics\\MyBitmap.bmp"));

    // Align the image and text on the button.
    button1.set_ImageAlign(ContentAlignment.MiddleRight);
    button1.set_TextAlign(ContentAlignment.MiddleLeft);

    // Give the button a flat appearance.
    button1.set_FlatStyle(FlatStyle.Flat);
} //SetMyButtonProperties
private function SetMyButtonProperties()
 {
    // Assign an image to the button.
    button1.Image = Image.FromFile("C:\\Graphics\\MyBitmap.bmp");
    // Align the image and text on the button.
    button1.ImageAlign = ContentAlignment.MiddleRight;    
    button1.TextAlign = ContentAlignment.MiddleLeft;
    // Give the button a flat appearance.
    button1.FlatStyle = FlatStyle.Flat;
 }
 

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

ButtonBase-Klasse
ButtonBase-Member
System.Windows.Forms-Namespace
ImageList
ButtonBase.FlatStyle-Eigenschaft