2012-02-27 5 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; 
    } 
}