开发者

Showing The Output Of Statement In BalloonTipText In NotifyIcon

开发者 https://www.devze.com 2023-04-02 17:36 出处:网络
I have this statement: cmd = new SqlCommand(\"select name,lname from table1 where column1=\'\" + x + \"\'\");

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号