Hi,
I have managed to successfully add new tabs to a form for each URL listed in a text file.
This is what it looks like:
I have added button1 as what I would like is for the tabs to cycle through in a loop, staying on each tab for lets say 5 seconds.
I have tried this:
$button1_Click = {
while (1 -eq 1)
{
$tabcontrol1.SelectedIndex++
UpdateNavButtons
Start-Sleep -s 5
$i++
}
}
The tabs cycle through but the form becomes inoperable and basically "freezes" the form. Also once it has reached the last tab it will not go further as it hits a virtual 'wall'...
Any ideas at all how to have the tabcontrol's tabs cycle through displaying each tab for X time in a continuous loop.
After this my project for this form will be complete so really would be helpful. thanks
Loop cycle through tabcontrol tabs
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.
Re: Loop cycle through tabcontrol tabs
Your code runs in an infinite loop. Here is the correct way to prevent infinite loops. Use a deterministic loop.
Code: Select all
$button1_Click={
for ($i = 0; $i -lt $tabControl1.TabCount;$i++) {
$tabcontrol1.SelectedIndex = $i
Write-Host $tabcontrol1.SelectedTab.Name
UpdateNavButtons
Start-Sleep -Seconds 5
}
Write-Host finished
}
-
- Posts: 18
- Last visit: Thu Apr 18, 2019 7:07 am
Re: Loop cycle through tabcontrol tabs
Thanks for this.
It works in terms of it cycles through the tabs however whilst cycling, the content of the tabs do not display as it seems while the process is running it locks up the form until its over...
I hope this makes sense? Please try recreating to see issue i am having if not clear.
many thanks
It works in terms of it cycles through the tabs however whilst cycling, the content of the tabs do not display as it seems while the process is running it locks up the form until its over...
I hope this makes sense? Please try recreating to see issue i am having if not clear.
many thanks
-
- Posts: 18
- Last visit: Thu Apr 18, 2019 7:07 am
Re: Loop cycle through tabcontrol tabs
The code cycles through the tabs successfully. But the tab contents do not display, and the GUI is unclickable while the loop is running. Only once the tab have completed it's cycle does it show the page it finished on.
I would like to see each tab and tab contents one by one in a loop
I would like to see each tab and tab contents one by one in a loop
Re: Loop cycle through tabcontrol tabs
Yes. That is how forms work. Perhaps you need to rethink your design.
Loading a browser is a heavy lift. Loading a bunch of browsers is going to lock up the form until all of the loading is done,
Loading a browser is a heavy lift. Loading a bunch of browsers is going to lock up the form until all of the loading is done,
Re: Loop cycle through tabcontrol tabs
Demo of loading multiple tabs:
- Attachments
-
- Test-TabSelection.psf
- (25.03 KiB) Downloaded 120 times
Re: Loop cycle through tabcontrol tabs
Here is an even better way to generate tab pages with browser controls.
- Attachments
-
- Test-TabCreation.psf
- (10.25 KiB) Downloaded 107 times