我需要另一个表格的托盘通知。ControlPanel.cs(默认形式,此处为 notifyicon):
...
public partial class ControlPanel : Form
{
public string TrayP
{
get { return ""; }
set { TrayPopup(value, "test");}
}
public void TrayPopup(string message, string title)
{
TrayIcon.BalloonTipText = message;
TrayIcon.BalloonTipTitle = title;
TrayIcon.ShowBalloonTip(1);
}
Form1.cs(另一种形式):
...
public partial class Form1 : Form
{
public ControlPanel cp;
....
private void mouse_Up(object sender, MouseEventArgs e) {
cp.TrayP = "TRAY POPUP THIS";
}
在网上cp.TrayP = "TRAY POPUP THIS";
我得到一个 NullException。如果我将其更改为cp.TrayPopup("TRAY POPUT THIS", "test");
异常抛出任何东西。
如果我这样做:
private void mouse_Up(object sender, MouseEventArgs e) {
var CP = new ControlPanel();
CP.TrayPopup("TRAY POPUP THIS", "test");
}
,托盘弹出显示,但它会创建第二个托盘图标,然后从新图标显示气球提示。我能做些什么?PS:抱歉英语不好。