Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Form with a TabControl which contain 3 TabPage.
When I remove the second or third TabPage, the cursor will be on a textbox that is not on the TabControl and has smallest TabIndex. But when I remove the first one, the first
TabPage will be selected (It mean the cursor is on the TabPage). I don't know why? Can anyone explain? I really want it still focus on the textbox which is not on the TabControl and has smallest TabIndex.

What I have tried:

I try to get the next control which will be selected next by using Form.GetNextControl before remove the TabPage and set focus to this. It work but i don't think this is the best solution.
Posted
Updated 17-Aug-18 10:00am
v2
Comments
[no name] 16-Aug-18 12:58pm    
Sometimes, a "workaround" is the only answer.

Which "event handlers" get fired when a Tab is removed? Loses focus? Does a tab have focus? Which control on the tab had focus when the tab was deleted? Does it matter which control? etc.
Tan Nguyen Dang 16-Aug-18 23:36pm    
I remove it in onload event of the form. The cursor is on the tab of the tabpage, not focus to the control when i remove the first tabpage. Because of the business, I need the cursor is on the textbox which is not contained in the TabControl and has smallest TabIndex.
Thanks for your comment. ^_^

1 solution

i found something that worked for me, but don't know if it will work for you.

in the onload event try using
VB
tabcontrol1.tabpages.remove(tabpage1)
tabcontrol1.visible = false
tabcontrol1.visible = true


it's strange, but it does work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900