Sdílet prostřednictvím


ButtonBase.Image Vlastnost

Definice

Získá nebo nastaví obrázek, který je zobrazen v ovládacím prvku tlačítka.

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

Hodnota vlastnosti

Zobrazený Image na ovládacím prvku tlačítka. Výchozí hodnota je null.

Příklady

Následující příklad kódu používá odvozenou třídu Button a nastaví některé její společné vlastnosti. Výsledkem bude ploché tlačítko s textem vlevo a obrázkem vpravo. Tento kód vyžaduje, abyste měli rastrový obrázek s názvem MyBitMap.bmp uložený v C:\Graphics adresáři a aby byl zahrnut odkaz na System.Drawing obor názvů.

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

Poznámky

Image Při nastavení ImageList vlastnosti bude vlastnost nastavena na nullhodnotu a ImageIndex vlastnost bude nastavena na výchozí hodnotu -1.

Poznámka:

Pokud je vlastnost nastavena FlatStyle na FlatStyle.System, nebudou zobrazeny všechny obrázky přiřazené k Image vlastnosti.

Platí pro

Viz také