博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

DevExpress GridControl数据的重定位

Posted on 2014-09-16 15:01  first_start  阅读(374)  评论(0)    收藏  举报

public void SetFouce(int rowHandle)
{
      for (int i = 0; i < this.gridView1.RowCount; i++)
      {
            gridView1.UnselectRow(i);
      }
      //当rowHandle是-1时选中最后一条(新增时使用)
      if (rowHandle == -1)
      {
            rowHandle = this.gridView1.RowCount;
      }
      if ((rowHandle != -1) && (this.gridView1.RowCount <= rowHandle))
      {
            rowHandle = this.gridView1.RowCount - 1;
      }
      this.gridView1.SelectRow(rowHandle);
      this.gridView1.FocusedRowHandle = rowHandle;
}