有一个功能,用户可以相互发送消息,并将其数据保存到表中。我在下面写了一个简单的代码来检查来自数据库的新消息:
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");
}
有效!现在我想在系统托盘上显示该消息框但应用已关闭...
如何在系统托盘上安装我的应用程序?
答案 0 :(得分: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&#34 ;;
如何用它创作?