System tray message alert when result > 0

本文关键字:gt result when tray message alert System | 更新日期: 2023-09-27 17:58:33

有一个函数,用户可以相互发送消息,并将其数据保存到表中。我在下面写了一个简单的代码,检查来自数据库的新消息:

lDataParameter.Add("msg", _msgEnd);
ultragrid1.DataSource = _msgEnd.Tables[0];
if (ultragrid1.Rows.Count > 0)
{
    ultragrid1.Rows[0].Selected = true;
    MessageBox.Show("You have" + ultragrid1.Rows.Count.ToString() + " 1 new message"); 
}

它有效!现在我想在系统托盘上显示那个消息框,但应用程序关闭了。。。

如何将我的应用程序放入系统托盘?

System tray message alert when result > 0

谢谢大家。我做到了。

 public Form1()
        {
            InitializeComponent();
            this.components = new System.ComponentModel.Container();
            this.contextMenu1 = new System.Windows.Forms.ContextMenu();
            this.menuItem1 = new System.Windows.Forms.MenuItem();
            // Initialize contextMenu1 
            this.contextMenu1.MenuItems.AddRange(
                        new System.Windows.Forms.MenuItem[] { this.menuItem1 });
            // Initialize menuItem1 
            this.menuItem1.Index = 0;
            this.menuItem1.Text = "E&xit";
            this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
            // Set up how the form should be displayed. 
            this.ClientSize = new System.Drawing.Size(292, 266);
            this.Text = "Notify Icon Example";
            // Create the NotifyIcon. 
            this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
            // The Icon property sets the icon that will appear 
            // in the systray for this application.
            notifyIcon1.Icon = new Icon("Icon.ico");
            // The ContextMenu property sets the menu that will 
            // appear when the systray icon is right clicked.
            notifyIcon1.ContextMenu = this.contextMenu1;
            // The Text property sets the text that will be displayed, 
            // in a tooltip, when the mouse hovers over the systray icon.
            notifyIcon1.Text = "Form1 (NotifyIcon example)";
            notifyIcon1.Visible = true;
            // Handle the DoubleClick event to activate the form.
            notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);
        }

现在我想创建更多的菜单这个。

menuItem1.Index=1;this.menuItem1.Text="I&nfo";

如何使用它进行创作?