ButtonBase.Image Vlastnost

Definice

Získá nebo nastaví obrázek, který je zobrazen na 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

Image

Zobrazí se 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ým 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, všechny obrázky přiřazené k Image vlastnosti se nezobrazí.

Platí pro

Viz také