2012-02-27 84 views
1

我正在使用Janus GridEx控件。我正在使用计时器每分钟更新数据库中的数据。如果用户在从数据库更新数据时选择了一行,那么如何在更新完成后重新选择该行?在运行时在GridEx中选择行

回答

4

您应该在刷新网格之前存储所选行的索引,然后将所选行设置为该值。例如:

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; 
    } 
}