ListViewDataItem.DisplayIndex 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 ListView 控制項中所顯示之資料項目的位置。
public:
virtual property int DisplayIndex { int get(); };
public virtual int DisplayIndex { get; }
public override int DisplayIndex { get; }
member this.DisplayIndex : int
Public Overridable ReadOnly Property DisplayIndex As Integer
Public Overrides ReadOnly Property DisplayIndex As Integer
屬性值
ListView 控制項中所顯示資料項目之以零起始的位置。
實作
範例
下列範例示範如何使用 DisplayIndex 屬性來擷取正在編輯之專案的索引。 此程式碼範例是為 方法提供之較大範例的 ListView.UpdateItem 一部分。
protected void PreferredCheckBox_CheckedChanged(object sender, EventArgs e)
{
// Gets the CheckBox object that fired the event.
CheckBox chkBox = (CheckBox) sender;
// Gets the item that contains the CheckBox object.
ListViewDataItem item = (ListViewDataItem) chkBox.Parent.Parent;
// Update the database with the changes.
VendorsListView.UpdateItem(item.DisplayIndex, false);
}
Protected Sub PreferredCheckBox_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
' Gets the CheckBox object that fired the event.
Dim chkBox As CheckBox = CType(sender, CheckBox)
' Gets the item that contains the CheckBox object.
Dim item As ListViewDataItem = CType(chkBox.Parent.Parent, ListViewDataItem)
' Update the database with the changes.
VendorsListView.UpdateItem(item.DisplayIndex, False)
End Sub
備註
屬性 DisplayIndex 會對應至 控制項所顯示 ListView 之專案的目前位置。 每個專案 DisplayIndex 的值都會反映新增至該特定資料頁控制項的順序。 您可以使用 DisplayIndex 屬性來擷取 ListViewDataItem 集合中的 Items 物件。
注意
此屬性只適用于資料項目。 它不適用於插入專案或空白專案。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應