ButtonBase.Image Tulajdonság

Definíció

Lekéri vagy beállítja a gombvezérlőn megjelenő képet.

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

Tulajdonság értéke

A Image gombvezérlőn látható. Az alapértelmezett érték a null.

Példák

Az alábbi példakód a származtatott osztályt használja, Button és beállítja annak néhány közös tulajdonságát. Az eredmény egy lapos gomb lesz, bal oldalon szöveggel, jobb oldalon pedig képpel. Ez a kód megköveteli, hogy a könyvtárban C:\Graphics egy bitképkép legyen elnevezveMyBitMap.bmp, és hogy szerepeljen a System.Drawing névtérre mutató hivatkozás.

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

Megjegyzések

Ha a Image tulajdonság be van állítva, a ImageList tulajdonság nullértéke a -1 lesz, a tulajdonság pedig az ImageIndex alapértelmezett értékre lesz állítva.

Note

Ha a FlatStyle tulajdonság értéke be van állítva FlatStyle.System, a Image tulajdonsághoz rendelt képek nem jelennek meg.

A következőre érvényes:

Lásd még