I'm trying to not make certain form control tabs not clickable on form load. List example below, wondering what i am missing, thanks
Example:
$tabcontrol1.Enabled = $false <-- will disable the whole tabcontrol
$tabpage2.Enabled = $false <-- disables the tabpage
Want to disable the $tabpage2 from not being clicked on to view the control.
GUI - Tab Control tabs - Disable/Not clickable
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.
- angelofstealth
- Posts: 69
- Last visit: Wed Sep 28, 2022 10:04 am
Re: GUI - Tab Control tabs - Disable/Not clickable
The following event will prevent selection of disabled tab pages:
- $tabcontrol1_Selecting=[System.Windows.Forms.TabControlCancelEventHandler]{
- #Event Argument: $_ = [System.Windows.Forms.TabControlCancelEventArgs]
- if(-not $_.TabPage.Enabled){
- $_.Cancel = $true
- }
- }
- angelofstealth
- Posts: 69
- Last visit: Wed Sep 28, 2022 10:04 am
Re: GUI - Tab Control tabs - Disable/Not clickable
This doesn't seem to work for me after a form load. I pasted this code after my form load and disabled the tabpages in the formload and they are still clickable.
Re: GUI - Tab Control tabs - Disable/Not clickable
In case OP or anyone else isn't too sure how to do this, the easiest way would be to select the control you wish to add the event to, click on the Events button in the Properties panel, and double click on the event you wish to add:jvierra wrote:You have to connect the event to the control for it to b e called.
DevinL
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: GUI - Tab Control tabs - Disable/Not clickable
As a shortcut, right click the control and select "add events" or just select the control and hit "Crtl-E". Check the event you want to add and click "Create". You will be placed in the edit pane in the new event.
When selecting a composite control be sure you have selected the container control and not an element. With Tab the pages usually get selected so be sure to click on the tab control and not on a page.
I have found that learning the shortcuts can save a tremendous amount of time and errors. They also help us to avoid having to search a long properties or events list on the "Properties" pane.
When selecting a composite control be sure you have selected the container control and not an element. With Tab the pages usually get selected so be sure to click on the tab control and not on a page.
I have found that learning the shortcuts can save a tremendous amount of time and errors. They also help us to avoid having to search a long properties or events list on the "Properties" pane.