Powershell 如果您不知道如何编写代码,请尝试学习或聘请开发人员。因此,这不是一个代码编写服务 function Show-sel_item_psf { [void][reflection.assembly]::Load('System.Windows.For

Powershell 如果您不知道如何编写代码,请尝试学习或聘请开发人员。因此,这不是一个代码编写服务 function Show-sel_item_psf { [void][reflection.assembly]::Load('System.Windows.For,powershell,Powershell,如果您不知道如何编写代码,请尝试学习或聘请开发人员。因此,这不是一个代码编写服务 function Show-sel_item_psf { [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') [void][reflection.assembly]::Load('System.Draw

如果您不知道如何编写代码,请尝试学习或聘请开发人员。因此,这不是一个代码编写服务
function Show-sel_item_psf {

    [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
    [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')

    [System.Windows.Forms.Application]::EnableVisualStyles()
    $form1 = New-Object 'System.Windows.Forms.Form'
    $tabcontrol1 = New-Object 'System.Windows.Forms.TabControl'
    $tabpage1 = New-Object 'System.Windows.Forms.TabPage'
    $checkedlistbox1 = New-Object 'System.Windows.Forms.CheckedListBox'
    $tabpage2 = New-Object 'System.Windows.Forms.TabPage'
    $checkedlistbox2 = New-Object 'System.Windows.Forms.CheckedListBox'
    $buttonOK = New-Object 'System.Windows.Forms.Button'
    $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'

    $list1 = @'
tabpage1
X008
X0011
X0013
tabpage2
Q008
M0013
'@

    $form1_Load={

    }

    $Form_StateCorrection_Load=
    {
        #Correct the initial state of the form to prevent the .Net maximized form issue
        $form1.WindowState = $InitialFormWindowState
    }

    $Form_Cleanup_FormClosed=
    {
        #Remove all event handlers from the controls
        try
        {
            $form1.remove_Load($form1_Load)
            $form1.remove_Load($Form_StateCorrection_Load)
            $form1.remove_FormClosed($Form_Cleanup_FormClosed)
        }
        catch { Out-Null <# Prevent PSScriptAnalyzer warning #> }
    }

    $form1.SuspendLayout()
    $tabcontrol1.SuspendLayout()
    $tabpage1.SuspendLayout()
    $tabpage2.SuspendLayout()

    $form1.Controls.Add($tabcontrol1)
    $form1.Controls.Add($buttonOK)
    $form1.AutoScaleDimensions = '6, 13'
    $form1.AutoScaleMode = 'Font'
    $form1.ClientSize = '193, 236'
    $form1.Name = 'form1'
    $form1.StartPosition = 'CenterScreen'
    $form1.Text = 'Form'
    $form1.add_Load($form1_Load)

    $tabcontrol1.Controls.Add($tabpage1)
    $tabcontrol1.Controls.Add($tabpage2)
    $tabcontrol1.Location = '12, 12'
    $tabcontrol1.Name = 'tabcontrol1'
    $tabcontrol1.SelectedIndex = 0
    $tabcontrol1.Size = '169, 192'
    $tabcontrol1.TabIndex = 2

    $tabpage1.Controls.Add($checkedlistbox1)
    $tabpage1.Location = '4, 22'
    $tabpage1.Name = 'tabpage1'
    $tabpage1.Padding = '3, 3, 3, 3'
    $tabpage1.Size = '161, 166'
    $tabpage1.TabIndex = 0
    $tabpage1.Text = 'tabpage1'
    $tabpage1.UseVisualStyleBackColor = $True

    $checkedlistbox1.CheckOnClick = $True
    $checkedlistbox1.FormattingEnabled = $True
    [void]$checkedlistbox1.Items.Add('X008')
    [void]$checkedlistbox1.Items.Add('X009')
    [void]$checkedlistbox1.Items.Add('X0010')
    [void]$checkedlistbox1.Items.Add('X0011')
    [void]$checkedlistbox1.Items.Add('X0012')
    [void]$checkedlistbox1.Items.Add('X0013')
    [void]$checkedlistbox1.Items.Add('X0014')
    [void]$checkedlistbox1.Items.Add('X0015')
    $checkedlistbox1.Location = '12, 10'
    $checkedlistbox1.Name = 'checkedlistbox1'
    $checkedlistbox1.Size = '136, 154'
    $checkedlistbox1.TabIndex = 1
    $checkedlistbox1.UseCompatibleTextRendering = $True

    $tabpage2.Controls.Add($checkedlistbox2)
    $tabpage2.Location = '4, 22'
    $tabpage2.Name = 'tabpage2'
    $tabpage2.Padding = '3, 3, 3, 3'
    $tabpage2.Size = '161, 166'
    $tabpage2.TabIndex = 1
    $tabpage2.Text = 'tabpage2'
    $tabpage2.UseVisualStyleBackColor = $True

    $checkedlistbox2.CheckOnClick = $True
    $checkedlistbox2.FormattingEnabled = $True
    [void]$checkedlistbox2.Items.Add('Q008')
    [void]$checkedlistbox2.Items.Add('Q009')
    [void]$checkedlistbox2.Items.Add('Q0010')
    [void]$checkedlistbox2.Items.Add('M0013')
    [void]$checkedlistbox2.Items.Add('M0014')
    [void]$checkedlistbox2.Items.Add('M0015')
    $checkedlistbox2.Location = '12, 10'
    $checkedlistbox2.Name = 'checkedlistbox2'
    $checkedlistbox2.Size = '136, 154'
    $checkedlistbox2.TabIndex = 2
    $checkedlistbox2.UseCompatibleTextRendering = $True

    $buttonOK.DialogResult = 'OK'
    $buttonOK.Location = '66, 206'
    $buttonOK.Name = 'buttonOK'
    $buttonOK.Size = '60, 26'
    $buttonOK.TabIndex = 1
    $buttonOK.Text = 'OK'
    $buttonOK.UseCompatibleTextRendering = $True
    $buttonOK.UseVisualStyleBackColor = $True
    $tabpage2.ResumeLayout()
    $tabpage1.ResumeLayout()
    $tabcontrol1.ResumeLayout()
    $form1.ResumeLayout()

    #Save the initial state of the form
    $InitialFormWindowState = $form1.WindowState
    #Init the OnLoad event to correct the initial state of the form
    $form1.add_Load($Form_StateCorrection_Load)
    #Clean up the control events
    $form1.add_FormClosed($Form_Cleanup_FormClosed)
    #Show the Form
    return $form1.ShowDialog()

}

#Call the form
Show-sel_item_psf | Out-Null
$list1 = "X008","X0011","X0013"
for($i = 0;$i -lt $checkedlistbox1.Items.Count;$i++) {
    if($list1.Contains($checkedlistbox1.Items[$i])) {
        $checkedlistbox1.SetItemChecked($i,$True)
    }
}