C# WinForm

C# 텍스트 박스 숫자만 입력

NicSub 2019. 2. 19. 19:09
728x90
반응형
1
2
3
4
5
6
7
8
private void txtInterval_KeyPress(object sender, KeyPressEventArgs e)
{
    //숫자만 입력되도록 필터링
    if(!(char.IsDigit(e.KeyChar) || e.KeyChar == Convert.ToChar(Keys.Back)))    //숫자와 백스페이스를 제외한 나머지를 바로 처리
    {
        e.Handled = true;
    }
}



출처: https://terrorjang.tistory.com/39 [개발자 공간]

반응형