As soon as my form loads it immediately checks the users current domain. If it's not an approved domain, all the form controls are disabled. Currently, I am doing an IF($ENV:USERDOMAIN -ne 'mydomain') and them manually enabling/disabling all the controls based on the results.
Is there a command that I can invoke that can set *all* the controls (or at least all the buttons) to 'Enabled = $false' ? I was thinking of adding all my control names to an array, and them doing a foreach...but i don't know if that's the best way (or even possible).
Thanks
One Click to rule them all?
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
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 LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
-
- Posts: 107
- Last visit: Thu Apr 29, 2021 8:47 am
One Click to rule them all?
First you must forge a function in the depths of Mount Doom that will iterate through all the controls and disable/enable them:
function Enable-Controls
{
param([bool]$Enabled, [System.Windows.Forms.Form]$Form)
foreach($control in $Form.Controls)
{
$control.Enabled = $Enabled
}
}
After you have forged this one function to disable them all you must wield it as thus:
Enable-Controls $false $form1
Note: Disabling the container control and it will disable all its children. For example, disabling a Groupbox will disable all the control contained within. You do not want to disable the form itself because the all windows system buttons such as the close X button will not work.
David
[PS. With a title like that you are just asking for a response like this ]
function Enable-Controls
{
param([bool]$Enabled, [System.Windows.Forms.Form]$Form)
foreach($control in $Form.Controls)
{
$control.Enabled = $Enabled
}
}
After you have forged this one function to disable them all you must wield it as thus:
Enable-Controls $false $form1
Note: Disabling the container control and it will disable all its children. For example, disabling a Groupbox will disable all the control contained within. You do not want to disable the form itself because the all windows system buttons such as the close X button will not work.
David
[PS. With a title like that you are just asking for a response like this ]
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.