DataGrid.CurrentRowIndex 属性    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置当前具有焦点的行的索引。
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, setPublic Property CurrentRowIndex As Integer属性值
当前行的从零开始的索引。
- 属性
例外
示例
下面的代码示例返回 .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 在链接到父表的子表中显示下一组记录。
如果用户正在查看父表或没有子关系的表,则该属性将返回当前行的从零开始的索引。