Non-clickable Context Menu Header

2019-06-17 01:41发布

When creating a context menu, is there a way to have header text included? For example, when a user clicks a button, I want a context menu to show with two options. There should also be text above the options, with a sentence such as: 'Please select an option'.

Is this possible?

2条回答
乱世女痞
2楼-- · 2019-06-17 01:45

You can't do it with the designer but you can do it in code:

public partial class Form1 : Form {
    public Form1() {
        InitializeComponent();
        contextMenuStrip1.Items.Insert(0, new ToolStripLabel("Please select an option"));
        contextMenuStrip1.Items.Insert(1, new ToolStripSeparator());
    }
}
查看更多
Animai°情兽
3楼-- · 2019-06-17 02:08

You can make a menu with 4 elements in this order:

  • "Please select an option" -Disabled (this make it gray out and unlickable)
  • Separator (------)
  • Option1 -Enabled
  • Option2 -Enabled
查看更多
登录 后发表回答