버튼을 클릭하여 C#에서 DataGridview의 현재 행을 변경하는 방법은 무엇입니까?datagridview 인덱스 변경
4
A
답변
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);
관련 문제
- 1. DataGridView 인덱스
- 2. DataGridView 셀 인덱스 문제
- 3. C# datagridview 잘못된 열 인덱스
- 4. Datagridview 색 변경
- 5. DataGridView 런타임에 디스플레이 변경
- 6. .Net DataGridView "인덱스 0에 값이 없습니다."
- 7. DataGridView ColumnOrder 새로 고침시 변경
- 8. NPGSQL + dataGridView + 코드에서 dg 변경
- 9. 런타임시 DataGridview 행 색상 변경
- 10. DataSource 변경 전 DataGridView 이벤트
- 11. DataGridView 셀의 단추 색 변경
- 12. 제스처 인식기의 인덱스 변경
- 13. 레일 3 - 인덱스 변경
- 14. ListBox, 인덱스 변경 선택
- 15. 스키마에서 인덱스 변경
- 16. 자바 스크립트 배열 인덱스 변경
- 17. Z- 인덱스 호버 경계 변경
- 18. 중첩 div의 Z- 인덱스 변경
- 19. sybase의 비 클러스터형 인덱스 변경
- 20. DataGridview 행에서 개별 셀의 스타일 변경
- 21. 단일 DataGridView 열의 모든 셀 패딩 변경
- 22. winforms datagridview 계산 된 필드 변경 이벤트
- 23. DataGridView 유효성 검사 및 셀 값 변경
- 24. 기존 값에 따라 DataGridView 값 변경
- 25. WinForm이 CellValueChanged 이벤트에서 DataGridView 변경 내용을 커밋하려고했습니다.
- 26. DataGridView 및 SelectedCells - 선택한 셀의 행 인덱스 찾기
- 27. DataGridView 내 하위 DataGridView
- 28. DataGridView HasErrors?
- 29. 사용자 지정 컨트롤의 DropDownList 인덱스 변경 없음!
- 30. iOS 테이블 뷰, 테이블 인덱스 프레임 변경
WinForms, WPF, ASP WebForms? – ChrisBD
WinForms에 있습니다. – Morteza