powershell - 处于关闭状态的 ComboBox 的鼠标事件处理程序
问题描述
这是我在其中寻找正确方法的代码,以在鼠标从列表中的一项移动到下一项时下拉处于按下状态时捕获任何鼠标移动。
Add-Type -AssemblyName System.Windows.Forms
$Form = New-Object System.Windows.Forms.Form
$Form.StartPosition = 'CenterScreen'
$cbSearch = New-Object System.Windows.Forms.ComboBox
$cbSearch.Width = 280
$cbSearch.Items.AddRange(@('Mixed content', 'More stuff', 'ANOTHER THING CONTENT', 'Item ?', 'Mixed item'))
$Form.Controls.Add($cbSearch)
# Event handler required for when the dropdown is in it's downed state. Like
# MouseCaptureChanged only when the dropdown is down and the mouse is moved over
# each item.
$cbSearch.Add_MouseCaptureChanged({ selectChanged $this $_ })
# Event handler action for the cbSearch control.
function selectChanged ($sender, $event) {
write-host ($cbSearch.Text)
}
[void]$Form.ShowDialog()
这可能吗?我已经尝试了所有可用的鼠标事件处理程序。
$cbSearch.Add_MouseCaptureChanged({ selectChanged $this $_ })
$cbSearch.Add_MouseEnter({ selectChanged $this $_ })
$cbSearch.Add_MouseHover({ selectChanged $this $_ })
$cbSearch.Add_MouseLeave({ selectChanged $this $_ })
这是我希望发生的事件是当悬停在每个项目上时。
解决方案
推荐阅读
- java - Java流收集到ConcurrentHashMap错误
- java - 创建游戏框架项目时失败
- flask - Flask 和 Auth0 - 如何检查用户是否在 Jinja 中经过身份验证
- sql - 用唯一组中的现有值填充空值
- python - 使用命名空间和 ElementTree 在 Python 3 中生成 XML 文档
- java - 检测到 RecyclerView 不一致。无效的视图支架适配器位置b - 在某些设备上崩溃
- android - 没有 runBlocking 的协程返回值
- javascript - 在点击框上显示像抽屉一样的滑块
- windows - 如何在 Windows 中使用“dir”命令根据上次更新时间对文件进行排序
- machine-learning - Logistic正态分布可以使用高斯的混合吗