구현된상태
List<class1> list1; private BindingSource source = new BindingSource(); source.DataSource = list; DataGridView grid; grid.DataSource = source; |
선택된 행삭제 방법
int rowIndex = grid.SelectedRows[0].Index; // BindingSource의 List에서 해당 항목 삭제 List<class1> list = source.DataSource as List<class1>; if (list != null && rowIndex >= 0 && rowIndex < list.Count) { list.RemoveAt(rowIndex); // BindingSource에 변경 사항 반영 source.ResetBindings(false); } |
'공부 > C#_자주쓸거' 카테고리의 다른 글
[C#][Winform] ListBox, ListView, TextBox 가장 아래 포커스 (0) | 2021.05.21 |
---|---|
[C#][Winform] 쓰레드 내부에서 컨트롤 수정 (0) | 2021.05.11 |