DataGrid.CurrentRowIndex プロパティ

定義

現在フォーカスがある行のインデックスを取得または設定します。

public:
 property int CurrentRowIndex { int get(); void set(int value); };
[System.ComponentModel.Browsable(false)]
public int CurrentRowIndex { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.CurrentRowIndex : int with get, set
Public Property CurrentRowIndex As Integer

プロパティ値

Int32

現在の行の 0 から始まるインデックス番号。

属性

例外

CurrencyManager がありません。

次のコード例では、 CurrentRowIndex.

private:
   void GetSelectedIndex( DataGrid^ myGrid )
   {
      Console::WriteLine( myGrid->CurrentRowIndex );
   }

   void SetSelectedIndex( DataGrid^ myGrid, int selIndex )
   {
      myGrid->CurrentRowIndex = selIndex;
   }
private void GetSelectedIndex(DataGrid myGrid){
    Console.WriteLine(myGrid.CurrentRowIndex);
 }
 
 private void SetSelectedIndex(DataGrid myGrid, int selIndex){
    myGrid.CurrentRowIndex = selIndex;
 }
Private Sub GetSelectedIndex(ByVal myGrid As DataGrid)
    Console.WriteLine(myGrid.CurrentRowIndex)
 End Sub
 
 Private Sub SetSelectedIndex(ByVal myGrid As DataGrid, ByVal selIndex As Integer)
    myGrid.CurrentRowIndex= selIndex
 End Sub

注釈

プロパティを現在の CurrentRowIndex 値以外の値に設定すると、指定した行が表示されるようにコントロールがスクロールされます。

この CurrentRowIndex プロパティを使用すると、子テーブルの行を表示している場合でも、親テーブルの行を反復処理できます。 たとえば、子テーブルを表示している場合は、インクリメント CurrentRowIndex すると、親テーブルにリンクされている子テーブル内の次のレコードセットが表示されます System.Windows.Forms.DataGrid

ユーザーが親テーブル、または子リレーションシップのないテーブルを表示している場合、プロパティは現在の行の 0 から始まるインデックスを返します。

適用対象

こちらもご覧ください