Guest User

Untitled

a guest
Nov 21st, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. 'this will select a tab page without changing the current focus
  2. 'https://stackoverflow.com/questions/4044711/select-tab-page-in-tabcontrol-without-stealing-focus
  3. Private Sub SelectTabWithoutFocus(tabPg As TabPage)
  4. 'cache the current focused control (ActiveControl), select the tab which makes it the current tab (and also sets the focus to the tab),
  5. 'and finally re-set focus to the original control.
  6. Dim prevFocusedControl = Me.ActiveControl
  7. If Me.ActiveControl IsNot Nothing Then
  8. tbcMain.SelectedTab = tabPg
  9. If prevFocusedControl.CanFocus Then prevFocusedControl.Focus()
  10. End If
  11. End Sub
Add Comment
Please, Sign In to add comment