Can anyone tell me how to get at the properties for the submenu in a ContextMenuStrip?
I know I can create a form and drop a context menu strip onto it. If I then add some items to the strip:
List item
- Pens
- -- Red
- -- Blue
- Markers
- -- Green
- -- Orange
I then write the following code:
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
this.contextMenuStrip1.AutoSize = false;
this.contextMenuStrip1.Height = 300;
this.contextMenuStrip1.Width = 150;
}
/// <summary>
/// Handles the MouseClick event of the Form1 control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
private void Form3_MouseClick_1(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
Point pt = this.PointToScreen(e.Location);
this.contextMenuStrip1.Show(pt);
}
}
}
The Top level menu showing Pens and Markers will be on a non autosized strip 150 * 300 but if i hover over Pens to get the sub menu, Red and Blue, this submenu will show up on a autosized strip!
How do I get at the sub menu properties so I can set it's height?