ErrorProvider의 셋팅
*
Public Class Form1

Private Sub ValiDataButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ValiDataButton.Click
If NameTextBox.Text.Length <= 0 Then
ErrorProvider1.SetError(NameTextBox, "이름을 넣으세요.")
Else
ErrorProvider1.Clear()
End If
If Not IsNumeric(AgeTextBox.Text) Then
ErrorProvider1.SetError(AgeTextBox, "나이를 넣으세요.")
Else
ErrorProvider1.Clear()
End If
End Sub

Private Sub NameTextBox_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles NameTextBox.Validating
If NameTextBox.Text.Length <= 0 Then
ErrorProvider1.SetError(NameTextBox, "이름를 넣으세여.")
e.Cancel = True
Else
ErrorProvider1.Clear()
End If
End Sub

Private Sub AgeTextBox_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles AgeTextBox.Validating

If Not IsNumeric(AgeTextBox.Text) Then
ErrorProvider1.SetError(AgeTextBox, "나이를 넣으세요.")
e.Cancel = True
Else
ErrorProvider1.Clear()
End If
End Sub
End Class

ErrorProvider는 조건의 불일치시 메세지를 출력하는 도구 입니다.. 

이 게시물을

공유하기

SEARCH

MENU NAVIGATION