Using this code in VB.Net in a textbox validating event, if we do not have the message box it acts as expected. That is, focus returns to the textbox and waits for further input. With a message box, the e.cancel seems to be ignored and focus moves to the next control. We have tried putting the message box both before and after the cancel and get the same results. What are we doing wrong?
If txtItemNo.Text <> "" Then
If GetData("ItemNo", txtItemNo.Text, "") <> "" Then
'do some success stuff
MessageBox.Show("Invalid item No!", "Validate Item No", MessageBoxButtons.OK, MessageBoxIcon.Error)
e.Cancel = True