简单实现系统托盘

实现

  1. 添加 contextMenu1 上下文菜单控件。

  2. 添加 notifyIcon1 控件。并设置 contextMenu 属性。

  3. 创建显示的图标

    private void Form1_Load(object sender, System.EventArgs e)
    {
        notifyIcon1.Icon = new System.Drawing.Icon("..\\..\\BICYCLE.ICO");
        notifyIcon1.Visible = true;
        notifyIcon1.Text = "BICYCLE";
    }
    
  4. 让图标不停的变幻

添加 timer控件

private void timer1_Tick(object sender, System.EventArgs e)
{
    if (notifyIcon1.Text == "BICYCLE")
    {
        notifyIcon1.Icon = new System.Drawing.Icon("..\\..\\CARS.ICO");
        notifyIcon1.Text="CARS";
    }
    else
    {
        notifyIcon1.Icon = new System.Drawing.Icon("..\\..\\BICYCLE.ICO");
        notifyIcon1.Text="BICYCLE";
    }
}
Contributors: FHL