| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- mybatis
- react
- 자바
- 리팩토링
- c#
- DataGridView
- Python
- kubernetes
- Winform
- 파이썬
- machine-learning
- docker
- Spring
- github
- Java
- springboot
- 마이바티스
- Kotlin
- design pattern
- AWS
- MySQL
- Spring Boot
- git
- 코틀린
- 쿠버네티스
- 스프링
- 도커
- 리액트
- 스프링부트
- VOA
Archives
- Today
- Total
보뇨 다이어리
dataGridView CurrentCell 이 null 인경우 본문
반응형
일단 코드부터 보자
코드상단부분에는 이미 dataGridView_student 의 초기화가 진행되어 자동으로 row 를 클릭할수있도록하는것이다
추가적으로 dataGridView_student 컴포넌트는 FullRowSelect 로 설정되어있다
dataGridView_student.Rows[0].Selected = true;
dataGridView_student_CellMouseUp(null, null);
그리고 다음 로직인 해당 부분을 탈때 에러가 발생한다
디버깅할때보니 CurrentCell 이나 CurrentRow 부분이 아예 null 이였다
근데 원인은 생각보다 간단했다 버그가 아닌가 싶기도하지만...
int index = dataGridView_student.CurrentCell.RowIndex;맨처음 코드를 보면 이미 초기화를 했다고 말했는데 그 첫번째 cells 부분을 visible = false 로 했었다
즉 첫번째 셀이 클릭조차 안된상태에서 초기화가 진행되었기에 null 을 뱉는것이였는데...이게 정상인가싶다
난 분명 FullRowSelect 인데말이지...그래서 좀 방법을 바꿔서 이렇게 진행하였더니 된다
아래 코드의 Cells[7] 은 visible = true 인 셀이다.
dataGridView_student.CurrentCell = dataGridView_student.Rows[0].Cells[7];
dataGridView_student.Rows[0].Selected = true;
dataGridView_student_CellMouseUpAsync(null, null);뭔가 티스토리에 마크다운안먹히는게 많은듯...
반응형
'컴퓨터 관련 > C# 정보' 카테고리의 다른 글
| dataGridView selected row 인덱스 가져오기 (0) | 2019.03.15 |
|---|---|
| PictureBox URL 이미지 가져오기 (0) | 2019.01.14 |
| MaskedTextBox 대신에 DateTimePicker 사용하기 (0) | 2019.01.14 |
| comboBox 내부 string align center 로 맞추기 (4) | 2019.01.07 |
| dataGridView 안에 특정 Row 감추기 (0) | 2018.12.12 |