-
C# DataGridView 추가행에 기본값 설정하기 (DefaultValuesNeeded 이벤트)프로그래밍/C# 2018. 12. 10. 14:43// DataGridView 이벤트 중에 DefaultValuesNeeded를 이용한다.private void dataGridView1_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e){// 이벤트로 넘어 온 DataGridView Row의 칼럼에 값을 넣는다.e.Row.Cells["Name"].Value = value;// 예제 코드e.Row.Cells["City"].Value = "Seoul";e.Row.Cells["Country"].Value = "Korea";}
cs 테스트 영상
행이 추가될 때 DefaultValuesNeeded 이벤트에 입력한 기본값이 바로 적용되지 않는다.
영상을 보면 알 수 있듯이 기본값은 추가행을 클릭하거나 다른 칼럼을 편집하기 위해 클릭을 했을 때 자동으로 입력된다.
'프로그래밍 > C#' 카테고리의 다른 글
C# DataGridView 열 전체 선택, 선택 풀기 (select row all or uselect row) (0) 2018.12.12 C# foreach DataRow in DataSet (0) 2018.12.11 C# DataGridView 추가행에 기본값 설정하기 (DefaultValuesNeeded 이벤트) (0) 2018.12.10 C# 웹통신 요청 및 응답 (WebRequest POST, WebResponse) (ContentType: application/x-www-form-urlencoded) (0) 2018.11.15 C# 우선순위 큐, Priority queue (1) 2018.11.07 C# JSON POST and GET (정보 전달 및 확인) (0) 2018.11.02