powershell - powershell gui选择列表突出显示

标签 powershell

我希望在那里我能很快得到答案。我基于选择的单选按钮填充列表框。我希望列表框自动突出显示行,以便当我单击按钮时可以根据选择进行相关操作。在这种情况下,它将是一个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()

关于powershell - powershell gui选择列表突出显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41106578/

相关文章:

powershell 从正文中获取特定行

powershell - 如何静默使用Invoke-Wuinstall

在发送带有附件的电子邮件的脚本结束后,PowerShell 仍然锁定文件

powershell - 是否有用于这些 AWS CLI 功能的 Azure 命令行界面

shell - Mongodb shell mongo : Only one usage of each socket address (protocol/network address/port) is normally permitted. 用于套接字 : 0. 0.0.0:27017

windows - 在命令提示符 (cmd.exe) 中运行 psm1 PowerShell 脚本?

powershell - Windows Powershell - 如何仅在某些 Windows 服务发生变化时重新显示它们的状态?

powershell - Get-CsUser 错误 powershell

powershell - 通过 '@' 提供输入文件会出现错误 : The splatting operator '@' cannot be used to reference variables in an expression

.net - Powershell ScriptBlock 不执行