Tuesday, April 5, 2011

Adding a horizontal separator in a MenuStrip

I can't seem to find any way to add a horizontal separator in a MenuStrip. Visual Studio complains Cannot add ToolStropSeparator to MenuStrip.

Any idea's how I can do this?

Thanks.

From stackoverflow
  • I'm able to run code like this:

    this.menuMain.Items.Add(new ToolStripSeparator());
    

    without any trouble... What kind of error are you getting?

    Malfist : I am using the GUI Designer and it tells me when I try to do '-' that 'Cannot add ToolStripSeparator to MenuStrip'
    Malfist : That works when I add it to the MainForm.Designer.cs, thanks!
    Malfist : Actually that doesn't work. It shows up in designer, but not when I actually run the program...
    Malfist : I added mnuMain.Items.Insert(2, new ToolStripSeparator()); to get the desired effect.

0 comments:

Post a Comment