Strange behavior with tabcontrol and tabpages

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
This topic is 6 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
cdouglas_nch
Posts: 16
Last visit: Wed Feb 28, 2024 10:55 am

Strange behavior with tabcontrol and tabpages

Post by cdouglas_nch »

Product, version and build: PowerShell Studio 5.4.140
32 or 64 bit version of product: 64 bit
Operating system: Windows 10
32 or 64 bit OS: 64 bit
PowerShell Version: 5.1

I'm seeing some behavior with a tabcontrol object and tabpages that I think is strange. I'm hoping someone can help clear it up.

I have a form that has a tabcontrol with 4 tabs. Near the tabcontrol object is a button that when clicked will set the selected tab for the tabcontrol to tabpage1. On each tabpage on enter an entry is written to a log file indicated that tabpageX was entered, and then "stuff" happens. Each tabpage also logs when it's left. What I'm seeing happen is that when I'm on tabpage3 (for example, happens regardless of which tab I'm on) and I click the button, I see the following in my log:

- Tabpage3 left
- Button has been clicked
- Tabpage3 entered
- Tabpage3 left
- Tabpage1 entered

What I would expect to see is:

- Button has been clicked
- Tabpage3 left
- Tabpage1 entered

Does anyone have any clue as to why I'm seeing this type of behavior? I only see this strange behavior when having the button click switch the tabs. If I use the mouse to click between the tabs it functions as expected.

Edit: My current work around is on the tabpage enter event, check to see if the current tabpage is visible. If it's not visible, then run the stuff it needs to. If the tabpage is visible during the enter event, then don't do anything.

Thanks,
Cody
Last edited by cdouglas_nch on Mon Jun 12, 2017 10:50 am, edited 1 time in total.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Strange behavior with tabcontrol and tabpages

Post by davidc »

[TOPIC MOVED TO THE POWERSHELL GUIS FORUM BY MODERATOR]
David
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Strange behavior with tabcontrol and tabpages

Post by jvierra »

It is not possible to guess without knowing how this is coded.
This topic is 6 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked