在Powershell中为contextmenustrip添加处理程序

时间:2013-06-26 08:33:46

标签: c# 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
}

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

像这样:

trayMenu.Items.Add("Login", ContextMenuStripItemImages).add_Click({... script here ...})

发件人用$this和e(EventArgs)代表$_