none
How can I create Menu seperator with .Net framework 2.0?

    Question

  • with .Net framework 1.1,I can implement menu seperator through setting the MenuItem's Text Property with a minus as shown below:

    MenuItem mi = new MenuItem();
    mi.Text = "-";

    but how can I achieve this with .Net Framework 2.0?
    it seems that the new class MenuStrip provided by .Net Framework 2.0 can not be manipulated  this way.
    any help tips will be appreciatedSmileSmile
    Friday, April 08, 2005 3:41 PM

Answers

  • You should be able to create a separator with code like this:

                ToolStripMenuItem newitem = new ToolStripMenuItem();
                newitem.Text = "&New";
                ToolStripMenuItem exitItem = new ToolStripMenuItem();
                exitItem.Text = "E&xit";
                ToolStripMenuItem fileitem = new ToolStripMenuItem();
                fileitem.Text = "&File";

               
    fileitem.DropDownItems.Add(newitem);
               
    fileitem.DropDownItems.Add(new ToolStripSeparator());
               
    fileitem.DropDownItems.Add(exitItem);

                MenuStrip
    menu = new MenuStrip();
               
    menu.Items.Add(fileitem);
               
    this.Controls.Add(menu);

    Note the "new ToolStripSeparator()"

    Sunday, April 10, 2005 10:08 PM
    Moderator

All replies

  • Dear Footballism (Strong name by the waySmile),
    I met an article at DevX that pretends to be the answer. I told it that you are the only one to tell so, would you agree with me on that ? ;-)
    Check and tell me.Idea
    Friday, April 08, 2005 4:02 PM
  • You should be able to create a separator with code like this:

                ToolStripMenuItem newitem = new ToolStripMenuItem();
                newitem.Text = "&New";
                ToolStripMenuItem exitItem = new ToolStripMenuItem();
                exitItem.Text = "E&xit";
                ToolStripMenuItem fileitem = new ToolStripMenuItem();
                fileitem.Text = "&File";

               
    fileitem.DropDownItems.Add(newitem);
               
    fileitem.DropDownItems.Add(new ToolStripSeparator());
               
    fileitem.DropDownItems.Add(exitItem);

                MenuStrip
    menu = new MenuStrip();
               
    menu.Items.Add(fileitem);
               
    this.Controls.Add(menu);

    Note the "new ToolStripSeparator()"

    Sunday, April 10, 2005 10:08 PM
    Moderator
  • how do i install net frame work?? i can't install it on win 7


    Wednesday, April 17, 2013 3:37 PM