Showing The Output Of Statement In BalloonTipText In NotifyIcon
I have this statement:
cmd = new SqlCommand("select name,lname from table1 where column1='" + x + "'");
I want to sho开发者_高级运维w the output of it in BalloonTipText in NotifyIcon, how can I do that?
from The MS notifyicon page, do you need to know how to execute the sql command also?
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("appicon.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 = SqlCommandResultsHere;
notifyIcon1.Visible = true;
// Handle the DoubleClick event to activate the form.
notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);
StringBuilder sb = new StringBuilder();
using (SqlDataReader rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
sb.AppendLine(rdr["name"].ToString() + ' ' + rdr["lname"].ToString());
}
}
notifyIcon.BalloonTipText = sb.ToString();
notifyIcon.ShowBallonTip(30000);
精彩评论