Tabcontrol sets focus to last tab after deletion

J

Josh Usovsky

I am dynamically adding and deleting tabs in a tabcontrol
at runtime. When I remove (RemoveAt()) a tabpage, focus
is automatically set to the final tabpage. I want focus
to remain on the tab that had focus before the event
occurred. How can I force the tabcontrol to not change
focus or at least make it appear that way? Setting the
focus immediately after the tabpage removal produces an
unseemly flash. Any suggestions?

Josh Usovsky
 
H

Herfried K. Wagner [MVP]

* "Josh Usovsky said:
I am dynamically adding and deleting tabs in a tabcontrol
at runtime. When I remove (RemoveAt()) a tabpage, focus
is automatically set to the final tabpage. I want focus
to remain on the tab that had focus before the event
occurred. How can I force the tabcontrol to not change
focus or at least make it appear that way? Setting the
focus immediately after the tabpage removal produces an
unseemly flash. Any suggestions?

This code shows how to detect when the selected tab changes:

<http://www.google.de/[email protected]>

Maybe you can use it.
 
G

Guest

Not quite what I was looking for, but thank you, just the
same. It seems like there should be a simpler way of
preventing this behavior without having to resort to
Win32 overrides and messy things like that. I don't
understand why this is the default behavior in the first
place.

--JU
 
H

Herfried K. Wagner [MVP]

* said:
Not quite what I was looking for, but thank you, just the
same. It seems like there should be a simpler way of
preventing this behavior without having to resort to
Win32 overrides and messy things like that. I don't
understand why this is the default behavior in the first
place.

IMO that's a bug.
 

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