我有这个带有“事件处理程序”的功能,但我无法在$event中定义操作部分的值,
$event=Register-ObjectEvent $Button click -SourceIdentifier $clickV -action {write-host $buttonV }
我有按钮但没有输出,请参见下面的函数参数,
如果我改变我的行:
$event=Register-ObjectEvent $Button click -SourceIdentifier $clickV -action {write-host "OK"}
我有按钮和输出
欢迎任何帮助,
Function Button
{
param(
[int]$EmplXButton,
[int]$EmplYButton,
[innt]$LongButton,
[int]$LargButton,
[string]$ButtonName,
[string]$clickV,
[int]$ButtonV
)
$Button = New-Object System.Windows.Forms.Button
$Button.Location = New-Object System.Drawing.Size($EmplXButton,$EmplYButton)
$Button.Size = New-Object System.Drawing.Size($LongButton,$LargButton)
$Button.Text = $ButtonName
$event=Register-ObjectEvent $Button click -SourceIdentifier $clickV -action {
write-host $buttonV ; Unregister-Event $clickV
}
$Button.Add_Click({$objForm.Close()})
$objForm.Controls.Add($Button)
}
Button 20 60 90 23 zero clickV0 0
Button 115 60 90 23 one clickV1 1
Button 210 60 90 23 two clickV2 2
Button 305 60 90 23 three clickV3 3
#>
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()