Home > OS >  C# form show notifications without any tray icon
C# form show notifications without any tray icon

Time:10-31

I want to use NotifyIcon, but I don't want any icons to appear in the lower right field, is this possible? Or does anyone have an alternative solution suggestion? I want to send a notification until the user sees the notification, the visibility will be turned on, but there will not be any icon in the lower right part. It will only appear in the notification panel on the right.

I tried to hide icon.But couldn't.

CodePudding user response:

Set NotifyIcon.Visible = false

alternatively you could use the Windows Toast notification if you are using .net5.0 or higher.

As described on Microsofts site, it only works with specific TFs.

.net6 is given on MS Site, for .net5 you can use <TargetFramework>net5.0-windows10.0.17763.0</TargetFramework>

CodePudding user response:

A workaround would be to only show the NotifyIcon during the time the notification is displayed and hide it immediately after. Here's a complete example:

public Form1()
{
    InitializeComponent();
    notifyIcon1.Visible = false;
    notifyIcon1.BalloonTipClosed  = notifyIcon1_BalloonTipClosed;
}

private void button1_Click(object sender, EventArgs e)
{
    notifyIcon1.Visible = true;
    notifyIcon1.ShowBalloonTip(1000, "Title", "Some text here", ToolTipIcon.Info);
}

private void notifyIcon1_BalloonTipClosed(object sender, EventArgs e)
{
    notifyIcon1.Visible = false;
}
  • Related