Freigeben über


ButtonBase.ImageAlign-Eigenschaft

Ruft die Ausrichtung des Bilds auf dem Schaltflächen-Steuerelement ab oder legt diese fest.

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

Syntax

'Declaration
<LocalizableAttribute(True)> _
Public Property ImageAlign As ContentAlignment
'Usage
Dim instance As ButtonBase
Dim value As ContentAlignment

value = instance.ImageAlign

instance.ImageAlign = value
[LocalizableAttribute(true)] 
public ContentAlignment ImageAlign { get; set; }
[LocalizableAttribute(true)] 
public:
property ContentAlignment ImageAlign {
    ContentAlignment get ();
    void set (ContentAlignment value);
}
/** @property */
public ContentAlignment get_ImageAlign ()

/** @property */
public void set_ImageAlign (ContentAlignment value)
public function get ImageAlign () : ContentAlignment

public function set ImageAlign (value : ContentAlignment)

Eigenschaftenwert

Einer der ContentAlignment-Werte. Der Standardwert ist MiddleCenter.

Ausnahmen

Ausnahmetyp Bedingung

InvalidEnumArgumentException

Der zugewiesene Wert ist keiner der ContentAlignment-Werte.

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
TextAlign