Tab control -switching

  • Thread starter Thread starter JPS
  • Start date Start date
J

JPS

A user is on a control (textbox) on a tab and I have code in the leave
event of the textbox that must validate input.
After typing in the text box the user then clicks on another tab.
My leave event fires (text box), and I try and set focus back on the
textbox, but the tab control does not let me. Instead the user goes to
the next selected tab after saying OK to my dialog box (leave event).
How can I keep them focused on the correct tab?
 
Don't use the Leave event to do validation. Use the Validating event,
and set e.Cancel = true on the event arguments if validation fails. The
user will not be able to leave the text box if validation fails.
 
Back
Top