Hello,
I have a loop to test file dates on a server list
For each server I want to display an image in the GUI PowerShell Studio
My script in my loop is :
$icoActivation = '$' + $node + 'KoStatus'
$icoActivation.Visible = $true
And the error is : The properties "Visible" is not existe for this object
Do you have an idea for me?
Regards
Variable and .visible fonction
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: Variable and .visible fonction
That is correct. The variable is a string and strings do not have a "visible" property.
$icoActivation = '$' + $node + 'KoStatus'
$icoActivation.GetType()
Why would you want a string to be visible. I suspect you have an icon object that is what you really want to make visible,
$icoActivation = '$' + $node + 'KoStatus'
$icoActivation.GetType()
Why would you want a string to be visible. I suspect you have an icon object that is what you really want to make visible,
Re: Variable and .visible fonction
Your use of $node seems to indicate that this is a TreeView question. See the following article section for help using images with nodes.
https://info.sapien.com/index.php/guis/ ... #imagelist
https://info.sapien.com/index.php/guis/ ... #imagelist
- adminmicro
- Posts: 13
- Last visit: Wed Dec 06, 2023 8:31 am
Re: Variable and .visible fonction
Thanks for your help
$icoActivation.Visible is a picturebox
I have a picturebox for each node (Picturebox for services OK, Picturebox for service Ko)
The name type for the picturebox is %ServerName%SrvOk (For exemple Poller01srvok)
Since I'm using a foreach loop, I'm looking for how to indicate the variable with the visible function
foreach ($node in $listAPE)
{
$sqlnetAPE = Get-Item ......
if ($sqlnetAPE -eq $sqlnet)
{
$icoActivation = '$' + $node + 'srvok'
$icoActivation.Visible = $true
}
else
{
$icoActivation = '$' + $node + 'srvKo'
$icoActivation.Visible = $true
}
}
$icoActivation.Visible is a picturebox
I have a picturebox for each node (Picturebox for services OK, Picturebox for service Ko)
The name type for the picturebox is %ServerName%SrvOk (For exemple Poller01srvok)
Since I'm using a foreach loop, I'm looking for how to indicate the variable with the visible function
foreach ($node in $listAPE)
{
$sqlnetAPE = Get-Item ......
if ($sqlnetAPE -eq $sqlnet)
{
$icoActivation = '$' + $node + 'srvok'
$icoActivation.Visible = $true
}
else
{
$icoActivation = '$' + $node + 'srvKo'
$icoActivation.Visible = $true
}
}
Re: Variable and .visible fonction
The following line turns the picturebox into a string.
$icoActivation = '$' + $node + 'srvok'
To find a control by string name:
$form.Controls[$node + 'srvok'].Visible = $true
$icoActivation = '$' + $node + 'srvok'
To find a control by string name:
$form.Controls[$node + 'srvok'].Visible = $true
- adminmicro
- Posts: 13
- Last visit: Wed Dec 06, 2023 8:31 am
Re: Variable and .visible fonction
Thanks for your help
It works very well
Just for information, be careful to put the name of the form so that it works ($form for my is $formservicesstatus)
It works very well
Just for information, be careful to put the name of the form so that it works ($form for my is $formservicesstatus)
Re: Variable and .visible fonction
There is no way for us to know the name of your form.adminmicro wrote: ↑Thu Jan 23, 2020 6:53 am Thanks for your help
It works very well
Just for information, be careful to put the name of the form so that it works ($form for my is $formservicesstatus)
- adminmicro
- Posts: 13
- Last visit: Wed Dec 06, 2023 8:31 am
Re: Variable and .visible fonction
No problem, This is just a clarification for other readers.
Regards
Regards