ButtonBase.Image プロパティ

定義

ボタン コントロールに表示されるイメージを取得または設定します。

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

プロパティ値

ボタン コントロールに表示される Image。 既定値は null です。

次のコード例では、 派生クラスを使用し、 Button その共通プロパティの一部を設定します。 結果は、左側にテキストが表示され、右側に画像が表示されたフラット ボタンになります。 このコードでは、 という名前 MyBitMap.bmp のビットマップ イメージをディレクトリに C:\Graphics 格納し、名前空間への参照を System.Drawing 含める必要があります。

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

注釈

プロパティが Image 設定されている場合、 ImageList プロパティは に null設定され、 ImageIndex プロパティは既定の -1 に設定されます。

Note

プロパティが FlatStyle に設定されている場合、プロパティにFlatStyle.SystemImage割り当てられているイメージは表示されません。

適用対象

こちらもご覧ください