Tab control -switching

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?
 
B

Bruce Wood

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top