2014-04-15 2 views
0

사용자가 서로 메시지를 보내고 테이블에 데이터를 저장할 수있는 기능이 있습니다. 그리고 나는 데이터베이스에서 그 수표의 새 메시지 아래에 간단한 코드를 썼습니다 :결과가 0 일 때 시스템 트레이 메시지 경고

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"); 
} 

그것은 작동합니다! 이제는 시스템 트레이에 해당 메시지 상자를 표시하고 싶지만 앱은 닫습니다 ...

시스템 트레이에서 내 응용 프로그램을 얻는 방법은 무엇입니까?

+3

[NotifyIcon] (http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx)을 찾으십시오. –

+0

이 가이드 사용 : https://www.simple-talk.com/dotnet/.net-framework/creating-tray-applications-in-.net-a-practical-guide/ – OuSs

+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";

어떻게 만드시겠습니까?