![由另一个表单事件触发的 PowerShell 表单事件](https://linux22.com/image/722994/%E7%94%B1%E5%8F%A6%E4%B8%80%E4%B8%AA%E8%A1%A8%E5%8D%95%E4%BA%8B%E4%BB%B6%E8%A7%A6%E5%8F%91%E7%9A%84%20PowerShell%20%E8%A1%A8%E5%8D%95%E4%BA%8B%E4%BB%B6.png)
我已经创建了一个表单(在 PowerShell Studio 中),我想知道是否可以查看哪个事件触发了另一个事件?示例
$button1_Click = {
$combobox1.Text = 'This is a test'
}
$combobox1_SelectedIndexChanged = {
Write-Host "I was triggered by button1!" #Is this possible?
}
非常感谢您的帮助!
答案1
谢谢EBGreen谢谢你的帮助建议!
$button1_Click = {
$global:buttonClicked = $true
$combobox1.Text = 'This is a test'
}
$combobox1_SelectedIndexChanged = {
If ($buttonClicked -eq $true)
{
Write-Host "I was triggered by button1!"
}
Else
{
Write-Host "I was triggered by user action!"
}
$global:buttonClicked = $false
}