PowerShell Studio dynamic checkbox naming issue

对着背影说爱祢 提交于 2019-12-11 15:09:32

问题


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

}

来源:https://stackoverflow.com/questions/58625486/powershell-studio-dynamic-checkbox-naming-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!