Louie De Janeiru

Textbox에 숫자만 입력받기 본문

C#

Textbox에 숫자만 입력받기

Louiey 2019. 2. 11. 12:13

private void textBoxTargetTemp_KeyPress(object sender, KeyPressEventArgs e)

{

// 숫자와 백스페이스와 '.' 키를 제외한 나머지를 바로 처리

if (!(char.IsDigit(e.KeyChar) || e.KeyChar == Convert.ToChar(Keys.Back) || e.KeyChar == 46))    

{

e.Handled = true;

}

}


'C#' 카테고리의 다른 글

Screen Record  (0) 2020.09.16
Properties.Settings.Default  (0) 2019.09.24
Decimal point handling  (0) 2019.09.23
DataGridView double buffered enable  (0) 2019.06.12
TextBox text null check  (0) 2018.11.13