[英]Add handler for contextmenustrip in Powershell
我想將其轉換為Powershell,但我不太確定該怎么做。 重要的部分是為trayMenu項目創建一個處理程序。
NotifyIcon trayIcon;
ContextMenuStrip trayMenu;
trayMenu = new ContextMenuStrip();
trayMenu.Items.Add("Login", ContextMenuStripItemImages).Click += new EventHandler(Login_Click); //Create a new item in the context menu strip and link its Click event with Login_Click
trayIcon = new NotifyIcon();
trayIcon.ContextMenuStrip = trayMenu; //Set the ContextMenuStrip of trayIcon to trayMenu
}
private void Login_Click(object sender, EventArgs e)
{
//Do something when Login is clicked
}
在此先感謝您的幫助!
像這樣:
trayMenu.Items.Add("Login", ContextMenuStripItemImages).add_Click({... script here ...})
發件人用$this
和e(EventArgs)用$_
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.