반응형
if (System.Text.RegularExpressions.Regex.IsMatch(this.labelControl2.Text, "[^0-9]")) //정규식을 입력
{
MessageBox.Show("숫자만 입력하세요.");
this.labelControl2.Text = this.labelControl2.Text.Remove(this.labelControl2.Text.Length - 1);
}
빨간색글자로 된곳에 매개변수값을 원하는 정규식을 써 넣으면 된다.
반응형
'언어 > C#' 카테고리의 다른 글
[C#] MS-SQL 데이터 연동 해서 DataSet에 저장하는 방법 (0) | 2020.02.27 |
---|---|
[C#] SaveFileDialog 사용 텍스트 저장하기 (0) | 2020.02.27 |
[Windows Forms] 윈폼 버튼 클릭이벤트 메시지박스 출력하기 (0) | 2020.01.22 |