Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
powershell gui选择列表高亮显示_Powershell - Fatal编程技术网

powershell gui选择列表高亮显示

powershell gui选择列表高亮显示,powershell,Powershell,我希望在那里我能很快得到答案。Im根据所选单选按钮填充列表框。我希望列表框自动高亮显示该行,以便当我单击按钮时,可以根据选择执行相关操作。在本例中,它将是一个sql server实例。请参阅将其添加到ListBox1的代码摘录 ForEach ($Server in $Servers) { #$NL = "`r`n" [void] $ListBox1.Items.Add($Server)

我希望在那里我能很快得到答案。Im根据所选单选按钮填充列表框。我希望列表框自动高亮显示该行,以便当我单击按钮时,可以根据选择执行相关操作。在本例中,它将是一个sql server实例。请参阅将其添加到ListBox1的代码摘录

ForEach ($Server in $Servers)
                    {

                #$NL = "`r`n"

                [void] $ListBox1.Items.Add($Server)
                       #$ListBox1.Items.selectedItem
                }
例如:

$form = New-Object System.Windows.Forms.Form

$listbox = New-Object System.Windows.Forms.ListBox

$listbox.SelectionMode = "MultiSimple"

$listbox.Items.Add("item1") | Out-Null
$listbox.Items.Add("item2") | Out-Null
$listbox.Items.Add("item3") | Out-Null
$listbox.Items.Add("item4") | Out-Null

for($i = 0; $i -lt $listbox.Items.Count; $i++) {
    $listbox.SetSelected($i, $true)
}

$form.Controls.Add($listbox)

$form.ShowDialog()

您好,您想在列表中自动选择什么?您好。刚刚添加的值。因此,如果在此循环中添加9行,将选择最后一行?不应突出显示“全部”。
$ListBox1.SelectAll()
?如果我想显示这些值,或者基本上对每个值都做些什么。如何分配给变量。到目前为止,我有类似的$Button1.Text=“DoSomething”$Button1.BackColor=“Gray”$Button1.Add\u Click($DoSomething)$DoSomething={foreach($ListBox1.value中的objItem){}我已经更改了我的示例,现在您有一个
for
循环,您可以在
添加中单击
。谢谢。明天英国时间我会看一看。