Hi,
Before I begin i would like to thank everyone on Sapien Forums.
I have a tabcontrol with tabs. I can refresh the tab I'm on by mouse clicking in the tabs window and pressing F5.
I can also go to the next tab plus refresh the tab page with the navigation button:
$buttonNext_Click={
if($tabcontrol1.SelectedIndex -lt $tabcontrol1.TabCount - 1)
{
$tabcontrol1.SelectedIndex++
[System.Windows.Forms.SendKeys]::SendWait("{F5}")
}
UpdateNavButtons
}
What I can't figure out is how to shift the focus onto the current tab without moving to the next tab.
I've tried:
$tabcontrol1.SelectedIndex
[System.Windows.Forms.SendKeys]::SendWait("{F5}")
also with
$tabcontrol1.SelectedTab
$tabcontrol1.Select()
But powershell isn't "clicking" into the window with the ones I've tried.
I've ran out of ideas how to have powershell "click" into the current tabs window to shift the focus into it.
Hope this makes sense.
Thanks
How to select focus into current tab of TabControl
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
-
- Posts: 18
- Last visit: Thu Apr 18, 2019 7:07 am
Re: How to select focus into current tab of TabControl
You can set the currently displayed tab by selecting the tab. You are selecting the tab control. There is no "clicking" when selecting a tab.
$tabcontrol1.SelectedTab = $tabcontrol1.TabPages['tabPage3']
$tabcontrol1.SelectedTab = $tabcontrol1.TabPages['tabPage3']
-
- Posts: 18
- Last visit: Thu Apr 18, 2019 7:07 am
Re: How to select focus into current tab of TabControl
Nice one, thanks. I'm very nearly there.
Instead of naming the tab page (as all my tabs have the same name), I can use the tab number e.g.
$tabcontrol1.SelectedTab = $tabcontrol1.TabPages[1]
[System.Windows.Forms.SendKeys]::SendWait("{F5}")
Very nearly there now... How can I make the tab number dynamic so it sets the tab page number to what it currently on on the GUI form?
$CurrentTabNumber = ........
$tabcontrol1.SelectedTab = $tabcontrol1.TabPages[$CurrentTabNumber]
So if i click the first tab it will automatically insert [0], and [1] if the 2nd tab is selected, so on...
Thanks so much
Instead of naming the tab page (as all my tabs have the same name), I can use the tab number e.g.
$tabcontrol1.SelectedTab = $tabcontrol1.TabPages[1]
[System.Windows.Forms.SendKeys]::SendWait("{F5}")
Very nearly there now... How can I make the tab number dynamic so it sets the tab page number to what it currently on on the GUI form?
$CurrentTabNumber = ........
$tabcontrol1.SelectedTab = $tabcontrol1.TabPages[$CurrentTabNumber]
So if i click the first tab it will automatically insert [0], and [1] if the 2nd tab is selected, so on...
Thanks so much
Re: How to select focus into current tab of TabControl
Every page has a name. The name is not the text shown but is the "Name" property.
There is no such thing as tab number. The "TabPages" property of the control is an array. There is a "TabIndex".
If you click on a tab the index will be the tab page you clicked on. There is no need t do this as the clicked tab is the "SelectedTab".
"F5" does nothing in a form as the form receives the F5 but form do not have a refresh event.
There is no such thing as tab number. The "TabPages" property of the control is an array. There is a "TabIndex".
If you click on a tab the index will be the tab page you clicked on. There is no need t do this as the clicked tab is the "SelectedTab".
"F5" does nothing in a form as the form receives the F5 but form do not have a refresh event.
Re: How to select focus into current tab of TabControl
To refresh any control use the control "Refresh()" method.
$tabpage1.Refresh()
$tabcontrol1.Refresh()
$textbox1.Refresh()
You can capture the F5 key in the form or any control in the keypress event. What it does is custom in the code. There is no need to use "SendKeys".
$tabpage1.Refresh()
$tabcontrol1.Refresh()
$textbox1.Refresh()
You can capture the F5 key in the form or any control in the keypress event. What it does is custom in the code. There is no need to use "SendKeys".