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

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

ButtonBase.ImageIndex プロパティ

ボタン コントロール表示されているイメージイメージ リスト内でのインデックス値を取得または設定します

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

<LocalizableAttribute(True)> _
Public Property ImageIndex As
 Integer
Dim instance As ButtonBase
Dim value As Integer

value = instance.ImageIndex

instance.ImageIndex = value
[LocalizableAttribute(true)] 
public int ImageIndex { get;
 set; }
[LocalizableAttribute(true)] 
public:
property int ImageIndex {
    int get ();
    void set (int value);
}
/** @property */
public int get_ImageIndex ()

/** @property */
public void set_ImageIndex (int
 value)
public function get ImageIndex
 () : int

public function set ImageIndex
 (value : int)

プロパティ
ImageList 内でのイメージ位置を表す 0 から始まるインデックス既定値は -1 です。

例外例外
例外種類条件

ArgumentOutOfRangeException

代入された値が ImageIndex下限値より小さいです

解説解説

ImageIndex プロパティまたは ImageList プロパティ設定されている場合は、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作成されており、そこに Image1 つ以上割り当てられている必要がありますまた、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;
 }
 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

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

   

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



ButtonBase.ImageIndex プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS