我有一个应用程序,主要是通过 NotifyIcon 的 ContextMenuStrip 操作的
。 ToolStripMenuItems 有多个级别,用户可以通过它们。
问题是,当用户有两个屏幕时,MenuItems 会在没有可用空间时跳转到第二个屏幕。像这样:
我怎样才能强迫他们留在同一个屏幕上?我试图通过网络搜索,但找不到合适的答案。
这是我用来测试此场景的示例代码:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
var resources = new ComponentResourceManager(typeof(Form1));
var notifyIcon1 = new NotifyIcon(components);
var contextMenuStrip1 = new ContextMenuStrip(components);
var level1ToolStripMenuItem = new ToolStripMenuItem("level 1 drop down");
var level2ToolStripMenuItem = new ToolStripMenuItem("level 2 drop down");
var level3ToolStripMenuItem = new ToolStripMenuItem("level 3 drop down");
notifyIcon1.ContextMenuStrip = contextMenuStrip1;
notifyIcon1.Icon = ((Icon)(resources.GetObject("notifyIcon1.Icon")));
notifyIcon1.Visible = true;
level2ToolStripMenuItem.DropDownItems.Add(level3ToolStripMenuItem);
level1ToolStripMenuItem.DropDownItems.Add(level2ToolStripMenuItem);
contextMenuStrip1.Items.Add(level1ToolStripMenuItem);
}
}