0
C#에서 사용자가 십진수 (음수 및 양수) 만 입력 할 수있는 텍스트 상자가 있습니다.십진수 (양수 및 음수) 만있는 텍스트 상자의 유효성 확인
MaskedText Box를 사용하고 싶지 않습니다. 입력을 검증하기 위해 keypress 이벤트를 사용하여 구현하고 싶습니다.
어떻게하면됩니까?
감사합니다,
********* 편집 ********* 다양한 숫자 유형 ++
private void mytextbox_KeyPress(object sender, KeyPressEventArgs e)
{
if (((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != '.' &&e.KeyChar!='-'))
{
e.Handled = true;
}
if (e.KeyChar == '.')
{
if ((sender as TextBox).Text.IndexOf(e.KeyChar) != -1)
e.Handled = true;
}
if (e.KeyChar=='-' && (sender as TextBox).SelectionStart > 0)
{
e.Handled = true;
}
}
는 당신이 봤어 :
이 답변이를 accompish 다른 방법을 많이 가지고? http://stackoverflow.com/questions/7259128/limit-numbers-after-decimal-on-key-press-event – abramlimpin