TabControl: prevent user from changing page?

maria

New member
Joined
Jul 28, 2005
Messages
4
Programming Experience
1-3
Hi,
I have a tabControl with 3 tabpages. in the first one i have a textbox. i want if the textbox not contain any text to prevent the user from changing the tab and return focus to the textbox.
Does anyone know a way to do that?
 
You could use a custom tab control like this one (bottom of page) to disable the other tabs until there is text in the box.

Edit: Also "An OnSelectedIndexChanging Method has been added to the TabControl so that you may cancel selection of a TabPage" until there is text
 
Thanks for your reply. I'll check out the link for sure.

At last i make it work with the selectedIndexChange event but the problem is that the tab that it's being clicked it shows up for some seconds and then the focus go back to the first page to edit the textbox.

But finally i've changed the way of validating the form not by control every time but when the user submits the form at the end.

Thanks again
 
Just for the record

I had the same problem, trying to validate the input page by page. Tried it at the end but with so many pages i felt the user would feel happier if each page was validated as they proceeded.

The tabcontrol.selecetedindexchanged was difficult to use if the user selected more than 1 tab ahead of where they were so in the end i tried the code with other events and the mousedown event worked great....
 
Back
Top