DataGrid.CurrentRowIndex プロパティ
選択された行のインデックスを取得または設定します。
Public Property CurrentRowIndex As Integer
[C#]
public int CurrentRowIndex {get; set;}
[C++]
public: __property int get_CurrentRowIndex();public: __property void set_CurrentRowIndex(int);
[JScript]
public function get CurrentRowIndex() : int;public function set CurrentRowIndex(int);
プロパティ値
選択された行の 0 から始まるインデックス番号。
例外
例外の種類 | 条件 |
---|---|
Exception | CurrencyManager がありません。 |
解説
CurrentRowIndex プロパティを使用すると、子テーブルの行を表示していても、親テーブルの行を反復処理できます。たとえば、子テーブルを表示しているときに、 CurrentRowIndex をインクリメントすると、 System.Windows.Forms.DataGrid によって親テーブルへリンクされた次のレコードセットが子テーブルに表示されます。
ユーザーが、子リレーションシップがないテーブルまたは親テーブルを表示しているときは、プロパティによって現在の行の 0 から始まるインデックス番号が返されます。
使用例
[Visual Basic, C#, C++] CurrentRowIndex を返す例を次に示します。
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
[C#]
private void GetSelectedIndex(DataGrid myGrid){
Console.WriteLine(myGrid.CurrentRowIndex);
}
private void SetSelectedIndex(DataGrid myGrid, int selIndex){
myGrid.CurrentRowIndex = selIndex;
}
[C++]
private:
void GetSelectedIndex(DataGrid* myGrid){
Console::WriteLine(myGrid->CurrentRowIndex);
}
void SetSelectedIndex(DataGrid* myGrid, int selIndex){
myGrid->CurrentRowIndex = selIndex;
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
DataGrid クラス | DataGrid メンバ | System.Windows.Forms 名前空間 | CurrencyManager