I have a TextBox that should contain a file name. It's mandatory for the program to work so I've put:
Private Sub tbScanFilter_Validating(sender As Object, e As CancelEventArgs) Handles tbScanFilter.Validating
If tbScanFilter.Text.Length = 0 Then
e.Cancel = True
ErrorProvider1.SetError(tbScanFilter, "Filter is required.")
End If
End Sub
Near to the TextBox I've put a button (...) that will open the open file dialog window to select the file.
The issue is that if the TextBox is empty I the ErrorProvider1 will be set and will not allow the focus to move to the button.
So what I would like to do is something like
If destination <> button (...) then
If tbScanFilter.Text.Length = 0 Then
e.Cancel = True
ErrorProvider1.SetError(tbScanFilter, "Filter is required.")
End If
But how can I know which is the destination control? I've tried to check the Enter event of the button but is not fired before the validating.
Any idea? any help?