ButtonBase.ImageAlign Proprietà

Definizione

Ottiene o imposta l'allineamento dell'immagine sul controllo pulsante.

public:
 property System::Drawing::ContentAlignment ImageAlign { System::Drawing::ContentAlignment get(); void set(System::Drawing::ContentAlignment value); };
public System.Drawing.ContentAlignment ImageAlign { get; set; }
member this.ImageAlign : System.Drawing.ContentAlignment with get, set
Public Property ImageAlign As ContentAlignment

Valore della proprietà

ContentAlignment

Uno dei valori di ContentAlignment. Il valore predefinito è MiddleCenter.

Eccezioni

Il valore assegnato non è uno dei valori di ContentAlignment.

Esempio

L'esempio di codice seguente usa la classe Button derivata e imposta alcune delle relative proprietà comuni. Il risultato sarà un pulsante flat con testo a sinistra e un'immagine a destra. Questo codice richiede che sia presente un'immagine bitmap denominata MyBitMap.bmp archiviata nella C:\Graphics directory e che sia incluso un riferimento allo System.Drawing spazio dei nomi.

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 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

Si applica a

Vedi anche