ListViewDataItem.DisplayIndex プロパティ

定義

データ項目が 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 コントロールに表示される、0 から始まる位置。

実装

次の例では、 プロパティを 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使用して、コレクション内のオブジェクトをListViewDataItemItems取得できます。

注意

このプロパティは、データ項目にのみ適用されます。 項目の挿入や空の項目には適用されません。

適用対象

こちらもご覧ください