윈폼 사용할때 보면 데이터그리드뷰가 밋밋할 때가 있다 보기도 좋지않고...
그럴때 각 행마다 색을 다르게 하면 좀더 이쁘고 가독성도 좋다
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 | //짝수 홀수 열 색지정 // rows 대신 column을 쓰면 각 column 색이 바꿔집니다 ㅎㅎ for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (i % 2 != 0) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.FromArgb(240, 255, 240); } else { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.FromArgb(240, 255, 255); } } //짝수 홀수 열 색지정(한줄) dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Aqua; |
'Winform' 카테고리의 다른 글
winform 열 숨기기 (0) | 2019.01.30 |
---|---|
winform 헤더, 셀 값 가운데로 정렬 (0) | 2019.01.30 |
winform 차트 예제 (0) | 2019.01.30 |
winform 엑셀 저장(초고속) (0) | 2019.01.29 |
winform 엑셀 죽이기 완벽한 방법 (0) | 2019.01.29 |