我在这个点击按钮事件里写了,
int i = DataGrid.CurrentRowIndex.RowNumber + 1
DataGrid.Select(i);
DataGrid.UnSelect(i-1);可是出现了这种情况
光标移到了下一行(就是下一行的底色变成了选中的样子),但是最左侧的小箭头还是原地不动的,取到当前的RowIndex发现其实行号没有移动。麻烦高人指点下,多谢了

解决方案 »

  1.   

    把 DataGrid.CurrentRowIndex 赋下值吧
      

  2.   

    DataGridView有CurrentCell,可以dataGridView1.CurrentCell = dataGridView1.Rows[n].Cells[0];不知道DataGrid有该属性冒。
      

  3.   

    DataGridViewCell dc;
                            if (this.dataGridView2.CurrentCell.RowIndex != 0)
                                dc = this.dataGridView2[this.dataGridView2.CurrentCell.ColumnIndex, this.dataGridView2.CurrentCell.RowIndex - 1];
                            else
                                dc = this.dataGridView2[this.dataGridView2.CurrentCell.ColumnIndex, this.dataGridView2.CurrentCell.RowIndex];
                            this.dataGridView2.CurrentCell = dc;datagrid和datagridview是不是一样的呢?你可以尝试下
      

  4.   

    int i = DataGrid.CurrentRowIndex+ 1 ;
    DataGrid.Select(i); 
    DataGrid.UnSelect(i-1); 
    DataGrid.CurrentRowIndex = i ;这样就可以了