今天有个新的需求要求在查询数据之后,之前选中的行不会被重置,这就需要记录当前的焦点行,然后模拟点击选中。
首先我们要记录当前的焦点行:
//记录选中行
var focusRow = gridView3.FocusedRowHandle;
然后在查询数据,并刷新GridView的代码之后,还原选中行,并模拟点击:
//还原选中行,并模拟点击
this.gridView3.FocusedRowHandle = focusRow;
gridView3_RowClick(null, null);
private void gridView3_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
{
var OUTSTORE_ID = dSPLPS.TPLPS011.DataSet.Tables["TPLPS011"].Rows[this.gridView3.FocusedRowHandle]["OUTSTORE_ID"].ToString();
var INSTORE_ID = dSPLPS.TPLPS011.DataSet.Tables["TPLPS011"].Rows[this.gridView3.FocusedRowHandle]["INSTORE_ID"].ToString();
var GOODS_CODE = dSPLPS.TPLPS011.DataSet.Tables["TPLPS011"].Rows[this.gridView3.FocusedRowHandle]["GOODS_CODE"].ToString();
Inquery(OUTSTORE_ID, INSTORE_ID, GOODS_CODE);
}