구현된상태

  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);
            }

+ Recent posts