如何在BalloonTipClicked事件后打开网址

问题描述

用户单击url后如何打开NotifyIcon

这是我的代码

public void ShowNotofication(string messages,string url)
{
    var notification = new System.Windows.Forms.NotifyIcon()
    {
        Visible = true,Icon = System.Drawing.SystemIcons.@R_620_4045@ion,// optional - BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info,// optional - BalloonTipTitle = "My Title",BalloonTipText = messages,};
    notification.BalloonTipClicked += new EventHandler((sender,e) => OpenChrome(url));
    notification.ShowBalloonTip(5000);
}
public void OpenChrome(string url)
{
    Process process = new Process();
    process.StartInfo.FileName = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
    process.StartInfo.Arguments = url + " --new-window";
    process.Start();
}

显示通知,但从未调用OpenChrome方法

我该如何解决

解决方法

尝试将其更改为此:

notification.Click += new EventHandler((sender,e) => OpenChrome(url));

代替此:

notification.BalloonTipClicked += new EventHandler((sender,e) => OpenChrome(url));

然后浏览器将打开。