Menu Seperator Bug?

  • Thread starter Thread starter Terry
  • Start date Start date
T

Terry

I seem to remember that there was a post some time ago about a problem
with using separators in menus.

Basically I am getting an "Unhandled exception of type
system.notsupportedeception"

This happens below the following code line

this.mnuSeperator1.Text = "-";

If I remove this statement then all compiles without error.

Can anyone remind me how to prevent this?

Terry
 
Terry,

this code works and compiles for me without any problems

//menu declartions
private System.Windows.Forms.MainMenu myMainMenu;
private System.Windows.Forms.MenuItem mnuTestMenu;
private System.Windows.Forms.MenuItem mnuItem1;
private System.Windows.Forms.MenuItem mnuSeperator1;
private System.Windows.Forms.MenuItem mnuItem2;
private System.Windows.Forms.MenuItem mnuSeperator2;
private System.Windows.Forms.MenuItem mnuItem3;

//menu initializtion
this.myMainMenu = new System.Windows.Forms.MainMenu();
this.mnuTestMenu = new System.Windows.Forms.MenuItem();
this.mnuItem1 = new System.Windows.Forms.MenuItem();
this.mnuSeperator1 = new System.Windows.Forms.MenuItem();
this.mnuItem2 = new System.Windows.Forms.MenuItem();
this.mnuSeperator2 = new System.Windows.Forms.MenuItem();
this.mnuItem3 = new System.Windows.Forms.MenuItem();

//
// myMainMenu
//
this.myMainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuTestMenu});
//
// mnuTestMenu
//
this.mnuTestMenu.Index = 0;
this.mnuTestMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuItem1,
this.mnuSeperator1,
this.mnuItem2,
this.mnuSeperator2,
this.mnuItem3});
this.mnuTestMenu.Text = "Test";
//
// mnuItem2
//
this.mnuItem2.Text = "Item2";
//
// mnuSeperator1
//
this.mnuSeperator1.Text = "-";
//
// mnuItem1
//
this.mnuItem1.Text = "Item1";
//
// mnuSeperator2
//
this.mnuSeperator2.Text = "-";
//
// mnuItem3
//
this.mnuItem3.Text = "Item3";

//set the menu to form
this.Menu = this.myMainMenu;

Shak.
 
Back
Top