Frage

i am using this code under my form1_load

notifyIcon1.Visible = true; 
notifyIcon1.ShowBalloonTip(5000, "Welcome", "Hello " + User, ToolTipIcon.Info); 

I even checked my registery and the value was 1. Why is the baloon not showing? I do have a icon form my notify icon. and it is showing up. The Baloon is not though!

War es hilfreich?

Lösung

You may need to post the rest of the code that's in your form's load event, but here's a couple of suggestions:

  1. Make sure the form's Load event is actually hooked up.
  2. Make sure you've assigned an icon for the notify icon.

Also, note that the balloon tip isn't guaranteed to show. See the Remarks section on msdn's NotifyIcon.ShowBalloonTip Method article:

Remarks
Minimum and maximum timeout values are enforced by the operating system and are typically 10 and 30 seconds, respectively, however this can vary depending on the operating system. Timeout values that are too large or too small are adjusted to the appropriate minimum or maximum value. In addition, if the user does not appear to be using the computer (no keyboard or mouse events are occurring) then the system does not count this time towards the timeout.

Only one balloon tip can display on the taskbar at a time. Attempting to display a balloon tip when one is currently displayed on the taskbar causes the timeout value to be ignored. The behavior is slightly different depending on the operating system and whether the balloon tip is from another, or the same, application. When the second balloon tip is from another application, the first balloon tip will display for the minimum timeout value before the second appears, regardless of the value of timeout. In most cases, if the balloon tips are from the same application, the first balloon tip immediately closes when another call to the ShowBalloonTip method is made. In some cases the second balloon will open on top of the first balloon.

The title text will display in a bold font near the top of the balloon.

Andere Tipps

Looks like you forgot to set the Icon for it like this

notifyIcon1.Icon = SystemIcons.Exclamation;
notifyIcon1.Visible = true; 
notifyIcon1.ShowBalloonTip(5000, "Welcome", "Hello " + User, ToolTipIcon.Info); 

Also please read for more inormation on issues with NI http://www.csharp411.com/notifyiconshowballoontip-issues/

Here is some sample code for what @MetroSmurf has already mentioned. Note that this.InitializeComponent(); must be called before the NotifyIcon is shown (usually in the form constructor).

public Form1()
{
    this.InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
    notifyIcon1.Icon = new Icon(@"C:\SomePath\MyIcon.ico");
    notifyIcon1.Visible = true;
    notifyIcon1.ShowBalloonTip(5000, "Welcome", "Hello " + User, ToolTipIcon.Info);
}

Also ensure that windows is configured to allow notifications. In Windows 7 right-click taskbar, click Properties, Customize... in the notification area, tick the Always show all icons and notifications on the taskbar option, click OK.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top