|
C#의 Datagridview 이벤트중에 보면 EditingControlShowing이라는 이벤트가 있는데 그 이벤트핸들러를 선택해주고
다음과 같이 구현
다음과 같이 구현
private void ProductMargins_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { e.Control.KeyPress += new KeyPressEventHandler(Control_KeyPress); } //datagridview에 이벤트를 잡아줘야함 private void Control_KeyPress(object sender, KeyPressEventArgs e) { if ((e.KeyChar >= '0' && e.KeyChar <= '9') || (e.KeyChar == '.' || e.KeyChar == ',' || e.KeyChar == '\b')) { // Don't do anything, everything is good. } else { e.Handled = true; } }
'프로그래밍 > C#' 카테고리의 다른 글
C# 에서 도스 명령어 실행 (0) | 2010.11.04 |
---|---|
C#에서 코드가 실행되는 경로 얻기 (0) | 2010.11.03 |
C# postmessage를 이용하여 다른창에 입력보내기 (0) | 2010.11.03 |