Q:

Validation is not working after clicking button (similar to submit) in Win Form

I have a winForm which has two button and two controls. Enrollment button click requires validation from these two controls. Verification button does not need any validation. That why I can't set focus on those controls.
Control's validation is working fine under validating and textchange event. However If Enrollment button is clicked validation is not working.
And I am not wanting to copy and paste all the validation code under 
Enrollment Click. What could be the possible optimized solution??

Giving some sample code if some one wants to test.
Dim vIDErrorProvider As New ErrorProvider()
Dim vintResultIDParse As Integer

Private Sub txtEmployeeID_TextChanged(sender As Object, e As EventArgs) Handles txtEmployeeID.TextChanged
    If (txtEmployeeID.Text = String.Empty) Then

        vIDErrorProvider.SetError(txtEmployeeID, "ID is required!")

        Return
    Else
        vIDErrorProvider.Clear()
    End If

    If Not Int32.TryParse(txtEmployeeID.Text.ToString(), vintResultIDParse) Then
        vIDErrorProvider.SetError(txtEmployeeID, "Only Integer is allowed")
        Return
    Else
        vIDErrorProvider.Clear()
    End If

End Sub

Private Sub txtEmployeeID_Validating(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles txtEmployeeID.Validating

    If (txtEmployeeID.Text = String.Empty) Then

        vIDErrorProvider.SetError(txtEmployeeID, "ID is required!")

        Return
    Else
        vIDErrorProvider.Clear()
    End If

    If Not Int32.TryParse(txtEmployeeID.Text.ToString(), vintResultIDParse) Then
        vIDErrorProvider.SetError(txtEmployeeID, "Only Integer is allowed")
        Return
    Else
        vIDErrorProvider.Clear()
    End If

End Sub

 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
    Me.ActiveControl = Label1

End Sub

A:

You don't need to put any validation code in the TextChanged() event as validation will be automatically called when the control's focus is lost.
To handle the case of the Enrollment button click, put the following code in its Click() event to cause form-wide validation.
For Each c As Control In Controls
    c.Focus()
    Validate()
Next

See https://msdn.microsoft.com/en-us/library/ms950965.aspx#winforms03162004_topic2

