mercredi 30 octobre 2019

PowerShell Studio dynamic checkbox naming issue

giving the following PowerShell Studio Code, how can I call and disable the 'David Checkbox' under the 'Checkit' button. I know I am messing up on the checkbox declaration somehow because powershell does not recognize my checkbox as an object:

The property 'Enabled' cannot be found on this object. Verify that the property exists and can be set.

$accounts = "David", "Dave"

$buttonLoadLabels_Click = {
    $CheckBoxCounter = 1
    $accounts = 'didier','david'

    foreach ($account in $accounts)
    {

        $label = New-Object System.Windows.Forms.Label
        $label.Text = $account
        $label.TextAlign = 'MiddleCenter'
        $label.Font = $label1.Font
        $flowlayoutpanel1.Controls.Add($label)



        $CB = New-Object System.Windows.Forms.CheckBox
        $CB.Name = $account
        Write-Host $CB.Name
        $flowlayoutpanel1.Controls.Add($CB)




    }
}



$buttonCheckIt_Click = {


    $checkbox_David.Enabled = $false

}




$accounts = "David", "Dave"

$buttonLoadLabels_Click = {
    $CheckBoxCounter = 1
    $accounts = 'didier','david'

    foreach ($account in $accounts)
    {

        $label = New-Object System.Windows.Forms.Label
        $label.Text = $account
        $label.TextAlign = 'MiddleCenter'
        $label.Font = $label1.Font
        $flowlayoutpanel1.Controls.Add($label)



        $CB = New-Object System.Windows.Forms.CheckBox
        $CB.Name = $account
        Write-Host $CB.Name
        $flowlayoutpanel1.Controls.Add($CB)


    }
}


$buttonCheckIt_Click = {


    $checkbox_David.Enabled = $false

}



Aucun commentaire:

Enregistrer un commentaire