难以从选中的列表框中访问选中的项目

时间:2014-08-19 15:05:17

标签: powershell

我有一个创建一个选中列表框的功能,我无法弄清楚如何获取已检查的项目。

创建选中列表框的功能是:

function  Add_ListBoxChecked ($name, $parent, $range, $dock, $x, $y, $length, $height){
    $object = New-Object System.Windows.Forms.CheckedListBox
    $object.Location = New-Object System.Drawing.Point($x, $y)
    $object.Size = New-Object System.Drawing.size($length, $height)
    $object.Text = ""
    $object.CheckOnClick = $true
    $object.Dock = $dock
    $object.Items.AddRange($range)
    $variable = Get-Variable $name -ErrorAction 'SilentlyContinue'
    If ($variable -eq $null){
        New-Variable $name -Value $object -Scope global
        (Get-Variable $parent).Value.Controls.Add((Get-Variable $name).Value)
    }
    else {(Get-Variable $parent).Value.Controls.Add((Get-Variable $name).Value)}
}

调用复选框创建的函数是:

else {  
        if ((Get-Variable BuildList).Value.SelectedIndex -eq 1){
            $name = (Get-Variable CompaniesList).Value.Selecteditem + "name" + "Prod"
            $ListName = (Get-Variable CompaniesList).Value.Selecteditem
            $text = (Get-Variable CompaniesList).Value.Selecteditem + " " + (Get-Variable CurrentProdVersion).Value.Text
            Add_TabPage $name  CompaniesListTabControl 0 0 0 0 $text "none"
            Add_ListBoxChecked $ListName $name $ProdFiles "Fill" 0 0 100 100

        }

非常感谢您访问Checked Items的任何帮助。

0 个答案:

没有答案