2012-02-27 4 views

답변

2

+1 YURIY 또한 당신이 선택 화살표를 이동하려는 당신의 행이 다음 보이지 않으면

:

grid.FirstDisplayedScrollingRowIndex = grid.Rows[2].Index; 
DataGgridridView1.Refresh() 
grid.CurrentCell = grid.Rows[2].Cells(1) // need to ensure that this is an existing, visible cell 

grid.Rows[2].Selected = True 
+0

고마워, 효과가 있었다. – Morteza

2

당신이 선택한 행의 인덱스를 변경이 작동해야 의미하는 경우 :

: 당신이 행을 교환하려는 경우

private void button_Click(object sender, EventArgs e) 
{ 
    grid.ClearSelection(); 
    // Select the third row. 
    grid.Rows[2].Selected = true; 
} 

(예를 들면, 제 1 · 3 행의 교환 데이터), 여기에 옵션들

int currentRowIndex = 0; 
int newRowIndex = 2; 

var currentRow = grid.Rows[currentRowIndex]; 
var rowToReplace = grid.Rows[newRowIndex]; 

grid.Rows.Remove(currentRow); 
grid.Rows.Remove(rowToReplace); 
grid.Rows.Insert(currentRowIndex, rowToReplace); 
grid.Rows.Insert(newRowIndex, currentRow); 
+0

현재 행을 바꿉니다. 예를 들어, 현재 행 위치는 5입니다. 8로 변경하고 싶습니다. – Morteza

+0

@ user1235144 : 무슨 뜻인가요? 데이터가있는 행을 다른 위치로 이동 시키거나 선택을 변경하는 것입니까? –

+0

작은 검은 색 화살표를 다른 레코드로 변경하기 만하면됩니다. – Morteza