简体   繁体   English

Windows窗体通知图标无法正常工作

[英]windows form Notify Icon Not working properly

notify icon disappears after 2 or 3 seconds and i have to restart the application 2或3秒后,通知图标消失,我必须重新启动应用程序

I have tried this code but not working properly 我已经尝试过此代码,但无法正常工作


    private void Frm_Dashboard_Resize_1(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                Hide();
                notifyIcon1.Visible = true;
            }
        }

private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e) {

ShowInTaskbar = true; notifyIcon1.Visible = false; WindowState = FormWindowState.Normal; }

You are not showing the form in the NotifyIcon double click event. 您没有在NotifyIcon双击事件中显示表单。

Change your code to - 将您的代码更改为-

private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
        {

        Show(); //display the form
        this.WindowState = FormWindowState.Normal;
        notifyIcon1.Visible = false;
    }

Also, look at the Remarks section of the ShowBalloonTip method 另外,请查看ShowBalloonTip方法的“ 备注”部分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM