0

我有一个包含'System.Windows.Forms.CheckedListBox'对象的 PowerShell 表单。目前我可以一次选择多个复选框选项:

选中 2 个的 CheckedListBox

有没有一种简单的方法可以做出CheckedListBox唯一的选择?

选中 1 个的 CheckedListBox

还是我必须'onClick'在我的脚本中使用一些事件逻辑?

CheckListBox 属性:

$checkedlistbox2.BackColor = 'Control'
$checkedlistbox2.BorderStyle = 'None'
$checkedlistbox2.CheckOnClick = $True
$checkedlistbox2.ColumnWidth = 56
$checkedlistbox2.FormattingEnabled = $True
[void]$checkedlistbox2.Items.Add("W2K")
[void]$checkedlistbox2.Items.Add("WXP")
[void]$checkedlistbox2.Items.Add("WS7")
$checkedlistbox2.Location = '107, 284'
$checkedlistbox2.MultiColumn = $True
$checkedlistbox2.Name = "checkedlistbox2"
$checkedlistbox2.SelectionMode = 'None'
$checkedlistbox2.Size = '192, 15'
$checkedlistbox2.TabIndex = 66
4

1 回答 1

0

您是否尝试将 SelectionMode 属性更改为“One”?

$checkedlistbox2.SelectionMode = "One"

或者,您可以使用单选按钮控件,它一次只允许一个选择?像这样的东西:

$radioButton1 = New-Object System.Windows.Forms.RadioButton
$radioButton2 = New-Object System.Windows.Forms.RadioButton
$radioButton1.Checked = $True
$radioButton1.Name = "W2K"
$radioButton1.Text = "W2K"
$radioButton1.Location = New-Object System.Drawing.Point(10,10)
$radioButton2.Name = "WXP"
$radioButton2.Text = "WXP"
$radioButton2.Location = New-Object System.Drawing.Point(10,30)
$form.Panel1.Controls.Add($radioButton1)
$form.Panel1.Controls.Add($radioButton2)
于 2013-08-06T11:25:50.930 回答