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