ColumnHeader.ImageIndex 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定顯示在 ColumnHeader中的影像索引。
public:
property int ImageIndex { int get(); void set(int value); };
[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter))]
public int ImageIndex { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter))>]
member this.ImageIndex : int with get, set
Public Property ImageIndex As Integer
屬性值
顯示於 ColumnHeader的影像索引。
- 屬性
例外狀況
value 小於 -1。
備註
屬性ImageIndex指的是由SmallImageList包含 的ColumnHeader屬性ListView指定的影像索引。 若在包含 ListView的 上沒有SmallImageList集合,則 該ImageIndex性質返回 -1。 欄位中顯示的圖片通常用來表示欄位中項目的狀態。
ImageKey 與 ImageIndex 互斥,意即若其中一組被設定,另一組則被設為無效值並被忽略。 如果你設定了屬性 ImageKey ,屬性 ImageIndex 會自動設為 -1。 或者,如果你設定了屬性 ImageIndex ,則 ImageKey 會自動設定為空字串(“”)。
若 ImageList 屬性值改為 null,屬性會 ImageIndex 回傳其預設值 -1。 然而,該賦值 ImageIndex 會在內部保留,並在其他 ImageList 物件被指派到該 ImageList 屬性時使用。 如果新 ImageList 指派到該 ImageList 屬性 ImageList.ImageCollection.Count 的屬性值小於或等於該屬性的 ImageIndex 值減一(以考慮集合為零為基礎的索引), ImageIndex 則屬性值會調整為比 Count 屬性值小一。
例如,考慮一個按鈕控制項,其 ImageList 有三個圖片,屬性 ImageIndex 設為 2。 如果指派一個只有兩張圖片的新按鈕ImageListImageIndex,值會變為 1。