10

I am writing code in which if updates are available then I want to show a pop up message with balloon using C#. This is similar to "Java Updates available".

Balloon tool tip

With the help of the NotifyIcon class and the BalloonTipIcon property, I can show the icon in the notification area but not this type of message. Any suggestions will be helpful.

Blackwood
  • 4,504
  • 16
  • 32
  • 41

3 Answers3

15

You can use NotifyIcon for this.

this.WindowState = FormWindowState.Minimized;  
notifyIcon.BalloonTipIcon = ToolTipIcon.Info;
notifyIcon.BalloonTipTitle = "Notify Icon Test Application";
notifyIcon.BalloonTipText = "You have just minimized the application." + 
                            Environment.NewLine + 
                            "Right-click on the icon for more options.";

notifyIcon.ShowBalloonTip(5000);

This will generate popup like one as below:

enter image description here

You can find more details on this link.

Bhushan Firake
  • 9,338
  • 5
  • 44
  • 79
  • I am really sorry but it is not solving my purpose. I did gave it a try earlier also but I am getting this pop up in notification area. –  Mar 05 '13 at 04:36
  • 1
    @Arti So where do you want your popup to appear? – Bhushan Firake Mar 05 '13 at 04:37
  • 1
    @Arti Your question also says that you want the popup in notification? – Bhushan Firake Mar 05 '13 at 04:39
  • In the notification area as shown in the image. Using above code I am getting the icon but not the image with text in it. –  Mar 05 '13 at 04:39
  • 1
    notifyIcon1.Visible = true; notifyIcon1.Icon = SystemIcons.Exclamation; notifyIcon1.BalloonTipTitle = "Balloon Tip Title"; notifyIcon1.BalloonTipText = "Balloon Tip Text."; notifyIcon1.BalloonTipIcon = ToolTipIcon.Error; This is what I am writting in the code. –  Mar 05 '13 at 04:54
  • @Arti You may try this link[http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx] – Bhushan Firake Mar 05 '13 at 04:59
2

Got the correct output as desired with the below code.

notifyIcon1.Visible = true;
notifyIcon1.Icon = SystemIcons.Exclamation;
notifyIcon1.BalloonTipTitle = "Balloon Tip Title";
notifyIcon1.BalloonTipText = "Balloon Tip Text.";
notifyIcon1.BalloonTipIcon = ToolTipIcon.Error;
notifyIcon1.ShowBalloonTip(1000);

Thanks @Bhushan for your suggestion....

  • I put your exact code to the `Form1_Load` function, but it does not work. No Ballon shows after I start the program, only the icon and nothing happens on click. Of course I already created notifyIcon1 – Black Aug 03 '17 at 19:38
2

There is a very simple single-line command you can write for this, instead of doing all that bulky thing others suggest:

notifyIcon1.ShowBalloonTip(1000, "Text", "Title", ToolTipIcon.Warning);

Remember that you need to have first initialized the control in your application so that this code works. You are free to adjust the control's name and the command's parameters according to your needs.