Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-clickable Context Menu Header

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?

like image 760
Darren Young Avatar asked Jan 04 '11 15:01

Darren Young


2 Answers

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());
    }
}
like image 149
Hans Passant Avatar answered Sep 25 '22 07:09

Hans Passant


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
like image 27
Liviu Mandras Avatar answered Sep 25 '22 07:09

Liviu Mandras