如何在Powershell GUI中使用回车键进行2种不同的操作?
我有一个Powershell表单,它有一个使用自动完成功能的下拉菜单。我在回车键上有一个操作来运行一个按钮。
$xyz.AutoCompleteSource = 'CustomSource'
$xyz.AutoCompleteMode='SuggestAppend'
$xyz.AutoCompleteCustomSource=$autocomplete
"x", "y", "z" | % {$xyz.AutoCompleteCustomSource.AddRange($_) }
$Form.AcceptButton = $GoButton
在文本框中键入时,我希望能够按 Enter 接受下拉列表中突出显示的选项,然后再次按 Enter 以运行我的处理程序$GoButton。
这可能吗?
已解决:
我没有使用"New-Object System.Windows.Forms.TextBox",而是创建了一个组合框"New-Object System.Windows.Forms.Combobox"。
这允许第一次按"Enter"选择突出显示的选项,第二次按"enter"运行我的处理程序。