[C#]외부파일 실행

System.Diagnostics 참조 Process.Start(_strFile);

[C#]배열 가변크기로 사용하기

먼저 선언후 추가할 경우 Array.Resize (ref _arrSql, 배열길이);

[C#]데이터 그리드뷰 뿌려준후 정해진 위치로 가기 (focus 맞추기)

DataGridViewCell _dgvCell = dgvList.Rows[가고자하는 로우].Cells[1]; dgvList.FirstDisplayedCell = _dgvCell ; dgvList.CurrentCell = _dgvCell ;

데이터그리드뷰 열 초기화

dgvNaver.DataSource = XXXX; 형태로 입력이 되어있을경우 dgvNaver.Rows.Clear(); 가 먹지 않아서 일괄 삭제 처리 하였다 int k = dgvNaver.Rows.Count; for(int j = 1; j { dgvNaver.Rows.RemoveAt(0); }

[C#]delegate 와 event를 이용한 유저컨트롤에 이벤트 발생

유저 컨트롤에 속해 있는 텍스트 박스에 키프레스 이벤트를 발생시키고 싶을경우 네임스페이스단에 텍스트 박스 키프레스 이벤트를 대샌할 다음과 같은 델리게이트 선언 public delegate void dlg_KeyPress(object sender, KeyEventArgs e); 그리고 클래스 내부에 다음과 같은 이벤트 생성 public event dlg_KeyPress event_KeyPress; 실제 텍스트 박스의 키 프레스 이벤트에서 다음코드 입력 if (e.KeyCode == Keys.Enter) event_KeyPress(sender, e); 그리고 컴파일을 하게 되면 해당 사용자 컨트롤의 이벤트에 보면 event_KeyPress 가 보이게 된다 . 끝!!!

[C#]데이터 그리드 뷰(DataGridView)의 줄번호(행번호)보이도록 하기

private void dgvList_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { //=============================== //그리드 행번호 입력하는 부분 //=============================== if (e.ColumnIndex = 0) { e.Paint(e.ClipBounds, DataGridViewPaintParts.All); Rectangle _rect = e.CellBounds; _rect.Inflate(-2, -2); TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), e.CellStyle.Font, _rect, e.CellStyle.ForeColor, TextFormatFlags.Right); e.Handled = true; } }