I have a TabControl and I'm adding Tabpages to it programmatically. Each TabPage loads a UserControl in it, and each user control contains a few controls. For example:
TabPage1
UserControl1
TextBox1, TextBox2, TextBox3
TabPage2
UserControl2
TextBox4, TextBox5, TextBox6
Now I want that whenever the user changes the tab, the previously-focused control of that tab get focus again when the tab is selected again.
Example:
- Let's say the focus is on TabPage1 → UserControl1 → TextBox2
- Then I click on TagPage 2 → UserControl2 → TextBox4
- Then I again click on TabPage1 and I want TextBox2 get the focus.
What shall I do?
CodePudding user response:
Possible solution: