簡體   English   中英

與 NotifyIcon 一起使用時奇怪的 ContextMenuStrip 樣式

[英]Weird ContextMenuStrip style when used with NotifyIcon

我正在嘗試使用自定義菜單創建通知區域圖標,並且在大多數情況下都可以正常工作。

問題是,菜單設置了一個非常奇怪的樣式 - 檢查圖像。 你需要點擊這個小框來激活這個項目,點擊它周圍的區域什么也不做。

在此處輸入圖片說明

如何將樣式更改為可以單擊整個按鈕的標准樣式? 更改 Renderer 和 RenderMode 似乎沒有幫助。 這是我系統上唯一具有此菜單樣式的通知圖標。

            _trayIcon = new NotifyIcon();
            _trayMenuStrip = new ContextMenuStrip();

            _trayIcon.Icon = Resources.trayicon;
            _trayIcon.Text = Assembly.GetExecutingAssembly().GetName().Name;
            _trayIcon.ContextMenuStrip = _trayMenuStrip;
            _trayIcon.Visible = true;

            _trayMenuStrip.Items.Add(new ToolStripButton("&Configure...", null, OpenConfigManager));
            _trayMenuStrip.Items.Add(new ToolStripSeparator());
            _trayMenuStrip.Items.Add(new ToolStripButton("&Exit", null, (sender, args) => Application.Exit()));

正如 Hans Passant 所提到的,我錯誤地使用了 ToolStripButtons 而不是 ToolStripMenuItems。 更改這些后,一切看起來都很好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM