TabControl.SelectedIndexChanged event?

G

Guest

Hello,

The SelectedIndexChanged event of TabControl object occurs when a tabpage is
selected.

I need to do some processing when user selects a new tabpage but before the
SelectedIndex has changed to the newly set tabpage index. I would call such
an event SelectedIndexChanging which would be raised before
SelectedIndexChanged.

Is there such an event? Or a solution to my need?

Thanks in advance.
 
C

Claudio Grazioli

No, there is no such event.

But you could store the current Index. When the SelectedIndexChanged event
is fired you still know the old index because you saved it before. You can
then do your processing with the old index, store the new Index and go on.

hth
 
G

Guest

Thanks Claudio,

Let's say SelectedIndexChanged is fired and if some condition is not met you
don't want to change the tabpage and want to go back to the old one. So you
need to set the SelectedIndex to the old index in which case the
SelectedIndexChanged is fired again and I don't have a neat solution to get
around that event being fired the second time.
 
C

Claudio Grazioli

Thanks Claudio,

Let's say SelectedIndexChanged is fired and if some condition is not met you
don't want to change the tabpage and want to go back to the old one. So you
need to set the SelectedIndex to the old index in which case the
SelectedIndexChanged is fired again and I don't have a neat solution to get
around that event being fired the second time.

:

ok. that's not an easy one. at least I don't have a solution.

Some thoughts:
- Why do you let the user select an other tabpage at
all when this certain conditions are not?
I don't know what the conditions are, but I assume it
has to do with valid values in the controls of the
current TabPage. If so, if you use something like
validation, the user could not select another TabPage
as long as there are invalid values on the current
TabPage.
You could also hide the other TabPages as long as
not all values are valid.

just ideas...

Cheers
 

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