如何在我的C#应用​​程序中创建自己的事件,例如可用的默认事件?

Dra*_*aco 1 c# events event-handling

每当用户将鼠标悬停在应用程序上时,我都需要更新系统托盘图标的文本值.我注意到系统托盘图标不存在此类事件.是否可以为系统托盘图标创建悬停事件,如果是,我该如何完成它?

Mar*_*ell 5

怎么样挂钩NotifyIcon.MouseMove

作为一个基本的例子,这似乎工作(与NotifyIcona Form):

    public Form1() {
        InitializeComponent();
        notifyIcon1.MouseMove += delegate
        {
            notifyIcon1.Text = DateTime.Now.TimeOfDay.ToString();
        };
        notifyIcon1.Icon = SystemIcons.Hand;
        notifyIcon1.Visible = true;            
    }
Run Code Online (Sandbox Code Playgroud)