| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- Gitea 설치
- 시놀로지깃티설치
- 깃티설치
- 트레이아이콘
- toroisegit
- c#
- Re
- synology
- Gitea GPG
- Column
- checkbox
- CmdKey
- 깃티gpg
- Resident
- trayicon
- 깃티
- gitea
- gfd
- DataGridView
- 시놀로지
- DataTable
- jellyfin
- unable to boot the simulator
- LogonUI
- 젤리핀
- theme
- gitea설치
- Capcom
- Header
- Resident Evil
- Today
- Total
C O D I N G
DataGridView컬럼헤더에 Checkbox넣기 본문
DataGridView의 이벤트중 CellPainting 나 Load이벤트에
if (e.ColumnIndex == 0 && e.RowIndex == -1)
{
e.PaintBackground(e.ClipBounds, false);
Point pt = e.CellBounds.Location;the cell
int nChkBoxWidth = 15;
int nChkBoxHeight = 15;
int offsetx = (e.CellBounds.Width - nChkBoxWidth) / 2;
int offsety = (e.CellBounds.Height - nChkBoxHeight) / 2;
pt.X += offsetx;
pt.Y += offsety;
CheckBox cb = new CheckBox();
cb.Size = new Size(nChkBoxWidth, nChkBoxHeight);
cb.Location = pt;
cb.Checked = true;
cb.CheckedChanged += new EventHandler(dgvCheckBox_CheckedChanged);
((DataGridView)sender).Controls.Add(cb);
e.Handled = true;
}
해당코드 입력
넣고자 하는 컬럼헤더에 Check박스위치를 계산해서 새로 그려주는 코드와 체크박스 이벤트 추가하는 코드임
'Programming > C#' 카테고리의 다른 글
| Enum에서 정한 Name을 index로 가져오기 (0) | 2016.12.22 |
|---|---|
| DataGridview 컬럼헤더 체크박스를 눌렀을때 Sel, DeSel하기 (0) | 2016.12.01 |
| DataGridView의 Cell입력시 KeyPress / MaxLength 사용하기 (0) | 2016.11.30 |
| bool 배열 한번에 초기화 하기 (0) | 2016.11.23 |
| DataTable 사용방법 (0) | 2016.08.14 |