ButtonBase.ImageList プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ButtonBase.ImageList プロパティの意味・解説 

ButtonBase.ImageList プロパティ

ボタン コントロールに表示される Image を保持している ImageList を取得または設定します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説

ImageList プロパティまたは ImageIndex プロパティが設定されている場合は、Image プロパティが既定値の null 参照 (Visual Basic では Nothing) に設定されます。

メモメモ

ImageList プロパティ値が null 参照 (Visual Basic では Nothing) に変更された場合、ImageIndex プロパティは既定値 -1 を返します。ただし、代入された ImageIndex 値は内部で保持され、この ImageList プロパティに別の ImageList が割り当てられたときに使用されます。ImageList プロパティに割り当てられた新しい ImageList の ImageList.ImageCollection.Count プロパティ値が、ImageIndex プロパティに代入されている値から 1 を引いた値以下の場合 (コレクションが 0 から始まるインデックス番号であるため)、ImageIndex プロパティ値は Count プロパティ値より 1 小さい値に調整されます。たとえば、3 つのイメージがある ImageList を持ち、ImageIndex プロパティが 2 に設定されているボタン コントロールがあるとします。このボタンに、イメージが 2 つしかない新しい ImageList を割り当てると、ImageIndex 値は 1 に変更されます。

使用例使用例

派生クラス Button を使用して、ImageList プロパティと ImageIndex プロパティを設定するコード例を次に示します。このコードでは、ImageList が作成されており、そこに Image が 1 つ以上割り当てられている必要があります。また、C:\Graphics ディレクトリに MyBitMap.bmp という名前のビットマップ イメージが格納されている必要もあります。

Private Sub AddMyImage()
    ' Assign an image to the ImageList.
    ImageList1.Images.Add(Image.FromFile("C:\Graphics\MyBitmap.bmp"))
    ' Assign the ImageList to the button control.   
    button1.ImageList = ImageList1
    ' Select the image from the ImageList (using the ImageIndex property).
    
    button1.ImageIndex = 0
End Sub 'AddMyImage
private void AddMyImage()
 {
    // Assign an image to the ImageList.
    ImageList1.Images.Add(Image.FromFile("C:\\Graphics\\MyBitmap.bmp"));
    // Assign the ImageList to the button control.   
    button1.ImageList = ImageList1;
    // Select the image from the ImageList (using the ImageIndex property).
    
    button1.ImageIndex = 0;
 }
 
private:
   void AddMyImage()
   {
      // Assign an image to the imageList.
      imageList1->Images->Add( Image::FromFile( "C:\\Graphics\\MyBitmap.bmp"
 ) );
      // Assign the imageList to the button control.
      button1->ImageList = imageList1;
      // Select the image from the ImageList (using the ImageIndex property).
      button1->ImageIndex = 0;
   }
private void AddMyImage()
{
    // Assign an image to the ImageList.
    imageList1.get_Images().Add(Image.FromFile(
        "C:\\Graphics\\MyBitmap.bmp"));
    // Assign the ImageList to the button control.   
    button1.set_ImageList(imageList1);
    // Select the image from the ImageList (using the ImageIndex property).
    
    button1.set_ImageIndex(0);
} //AddMyImage
private function AddMyImage()
 {
    // Assign an image to the ImageList.
    ImageList1 = new ImageList;
    ImageList1.Images.Add(Image.FromFile("C:\\Graphics\\MyBitmap.bmp"));
    // Assign the ImageList to the button control.   
    button1.ImageList = ImageList1;
    // Select the image from the ImageList (using the ImageIndex property).
    
    button1.ImageIndex = 0;
 }
 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

ButtonBase.ImageList プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ButtonBase.ImageList プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS