DevExpress GridControl 按列值定位(选择)对应行
方法一:
int rowHandle = gridView.LocateByValue("CustomerID", 12345); if(rowHandle != DevExpress.XtraGrid.GridControl.InvalidRowHandle) gridView.FocusedRowHandle = rowHandle;
方法二:
int result = DevExpress.XtraGrid.GridControl.InvalidRowHandle;
for (int i = 0; i < gvNotice.RowCount; i++)
if (Equals(noticeId, gvNotice.GetRowCellValue(i, "ACCOUNTNOTICEID")))
{
result = i;
break;
}
if (result != DevExpress.XtraGrid.GridControl.InvalidRowHandle)
{
gvNotice.FocusedRowHandle = result;
gvNotice.SelectRow(result);
}