How to show a message with icon in the notification area

前端 未结 3 2094
执念已碎
执念已碎 2020-12-11 16:36

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\".

相关标签:
3条回答
  • 2020-12-11 16:41

    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.

    0 讨论(0)
  • 2020-12-11 16:56

    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....

    0 讨论(0)
  • 2020-12-11 17:04

    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.

    0 讨论(0)
提交回复
热议问题