Prevent the user from changing the selected tab page

  • Thread starter Thread starter Fabio
  • Start date Start date
F

Fabio

Hello,

Does anybody know how to prevent the user from changing
the selected tab page ? I found some code on the web that
suggest to use the CausesValidation event to cancel the
selectedindexchange event when the user switch between
tabs. However the causevalidation event is not supported
in the tabcontrol. Any help would be greatly appreciated.

Thanks

Fabio
Software Engineer
Metrix Inc.
 
Fabio,

Have you tried trapping the change event and just changing it back? I don't
think users will like this behavior though since it's not what they'd
expect.
 
Hello Ginny,

Thanks for your reply.

I agree with you about the behavior and I expressed the
same point of view within my company however the owner
wants the application to save records automatically
between tabs. The problem arise when the field within each
tabpages are not filled completely (required fields) or
the user does not want save and change her/his mind.

So when the user switch between tabs I am checking for
required fields and I pop up a message box that let the
user finish entering the data or continue without saving
(rejecting any changes).

The problem I have is when I reset the selectedindex on
the tabcontrol to the previous tab the code get stuck in a
recursive call, this approach is too clunky. So I was
looking for a better and cleaner solution.

I am developing in VB.NET and I found C# code in this
newsgroup that does prevent the user from switching tabs,
I ported over to VB.NET but it does not work that well.

Fabio
 
Fabio,

I do understand why you're doing it. I just felt I should also had my 2
cents about the practice. ;-) If each tab page represents a complete record
of data, why not use different forms instead of different tab pages? This
user interface would be more what a user would expect, I think. But if the
owner just likes tab pages that work funny, you can probably get around the
recursion problem by using a boolean property that you can set and unset to
indicate that you are controlling the tabbing (or not).
 
Back
Top