我正在使用Janus GridEx控件。我正在使用计时器每分钟用数据库中的数据更新网格。如果用户在从数据库更新数据时选择了行,那么在更新完成后如何重新选择行?
答案 0 :(得分:5)
您应该在刷新网格之前存储所选行的索引,然后将所选行设置为该值。类似的东西:
int row = myGrid.Row;
// Perform update
try
{
vJanusDataGridMeasures.Row = row;
}
// The row index that was selected no longer exists.
// You could avoid this error by checking this first.
catch (IndexOutOfRangeException)
{
// Check to see if there are any rows and if there are select the first one
if(vJanusDataGridMeasures.GetRows().Any())
{
vJanusDataGridMeasures.Row = 0;
}
}