共用方式為


ListIndex 屬性

識別 ListBoxComboBox中目前選取的專案。

語法

物件ListIndex [= Variant ]

ListIndex屬性語法具有下列部分:

部分 描述
物件 必要。 有效物件。
Variant 選用。 控制項中目前選取的專案。

註解

ListIndex 屬性包含清單中所選取列的索引。 Values of ListIndex range from -1 to one less than the total number of rows in a list (that is, ListCount - 1). When no rows are selected, ListIndex returns -1.

當使用者在 ListBoxComboBox 中選取列時,系統會設定 ListIndex 值。 清單中第一列的 ListIndex 值為 0,第二列的值為 1,以此類推。

注意事項

如果您使用MultiSelect屬性來建立允許多個選取專案的ListBox則 ListBoxSelected 屬性會 (而非ListIndex屬性,) 識別選取的資料列。 Selected屬性是陣列,其值數目與ListBox中的資料列數目相同。

For each row in the list box, Selected is True if the row is selected and False if it is not. 在允許多重選取的 ListBox 中, ListIndex 會 傳回具有 焦點之資料列的索引,無論該資料列目前是否已選取。

ListIndex值也可以透過將下拉式方塊或清單方塊的BoundColumn屬性設定為 0 來取得。 如果BoundColumn為 0,下拉式方塊或清單方塊所系結的基礎資料來源會包含與ListIndex 相同的清單索引值。

另請參閱

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應