ListBox.SelectedObjectCollection.Count 屬性

定義

取得集合中的項目數目。Gets the number of items in the collection.

public:
 property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer

屬性值

集合中的項目數目The number of items in the collection.

實作

備註

這個屬性可讓您判斷 ListBox中選取專案的數目。This property enables you to determine the number of selected items in the ListBox. 然後,您可以在迴圈處理集合的值時使用這個值,而您需要提供一些反復專案來執行迴圈。You can then use this value when looping through the values of the collection and you need to provide a number of iterations to perform the loop. 除非 ListBox 的 [SelectionMode] 屬性設定為 [SelectionMode.MultiSimple] 或 [SelectionMode.MultiExtended],否則此屬性一律會傳回值為零(0)或一(1),視您是否有選取的專案而定。Unless the SelectionMode property of the ListBox is set to SelectionMode.MultiSimple or SelectionMode.MultiExtended, this property always returns a value of zero (0) or one (1) depending on whether you have a selected item.

適用於