C# 结果显示时系统托盘消息警报>;0
有一个功能,用户可以互相发送消息,并将其数据保存到表中。我在下面写了一段简单的代码,检查数据库中的新消息:C# 结果显示时系统托盘消息警报>;0,c#,windows,winforms,system-tray,C#,Windows,Winforms,System Tray,有一个功能,用户可以互相发送消息,并将其数据保存到表中。我在下面写了一段简单的代码,检查数据库中的新消息: lDataParameter.Add("msg", _msgEnd); ultragrid1.DataSource = _msgEnd.Tables[0]; if (ultragrid1.Rows.Count > 0) { ultragrid1.Rows[0].Selected = true; MessageBox.Show("You have" + ultra
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");
}
它起作用了!现在我想在系统托盘上显示该消息框,但应用程序已关闭
如何将我的应用程序放在系统托盘上?谢谢各位。我做到了
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”
如何使用它进行创建?查找。使用本指南:没有系统托盘这样的东西。您正在查找通知区域。