0

当编译两个菜单时,我已经将这个单选按钮菜单条组合在一起,其中存在两个单独的子菜单项......怎么可能让它们并排?

这是截图... http://s7.directupload.net/file/d/3404/7dwpwbm5_jpg.htm

public Form1()
{

    mainToolStripMenuItem2.Text = "Eingabewert";
    toolStripRadioButtonMenuItem7.Text = "option 1";
    toolStripRadioButtonMenuItem8.Text = "option 2";
    toolStripRadioButtonMenuItem9.Text = "option 2-1";
    toolStripRadioButtonMenuItem10.Text = "option 2-2";
    toolStripRadioButtonMenuItem11.Text = "option 3-1";
    toolStripRadioButtonMenuItem12.Text = "option 3-2";
    toolStripMenuItem2.Text = "toggle";


    toolStripMenuItem2.CheckOnClick = true;
    mainToolStripMenuItem2.DropDownItems.AddRange(new ToolStripItem[] {
        toolStripRadioButtonMenuItem7, toolStripRadioButtonMenuItem8,
        toolStripMenuItem2});
    toolStripRadioButtonMenuItem10.DropDownItems.AddRange(
        new ToolStripItem[] {toolStripRadioButtonMenuItem11, 
        toolStripRadioButtonMenuItem12});
    toolStripMenuItem2.DropDownItems.AddRange(new ToolStripItem[] {
        toolStripRadioButtonMenuItem5, toolStripRadioButtonMenuItem6});

    mainToolStripMenuItem.Text = "Ausgabewert";
    toolStripRadioButtonMenuItem1.Text = "option 1";
    toolStripRadioButtonMenuItem2.Text = "option 2";
    toolStripRadioButtonMenuItem3.Text = "option 2-1";
    toolStripRadioButtonMenuItem4.Text = "option 2-2";
    toolStripRadioButtonMenuItem5.Text = "option 3-1";
    toolStripRadioButtonMenuItem6.Text = "option 3-2";
    toolStripMenuItem1.Text = "toggle";
    toolStripMenuItem1.CheckOnClick = true;

    mainToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] {
        toolStripRadioButtonMenuItem1, toolStripRadioButtonMenuItem2,
        toolStripMenuItem1});
    toolStripRadioButtonMenuItem2.DropDownItems.AddRange(
        new ToolStripItem[] {toolStripRadioButtonMenuItem3, 
        toolStripRadioButtonMenuItem4});
    toolStripMenuItem1.DropDownItems.AddRange(new ToolStripItem[] {
        toolStripRadioButtonMenuItem5, toolStripRadioButtonMenuItem6});

    menuStrip1.Items.AddRange(new ToolStripItem[] { mainToolStripMenuItem });
    menuStrip2.Items.AddRange(new ToolStripItem[] { mainToolStripMenuItem2 });
    Controls.Add(menuStrip1);
    Controls.Add(menuStrip2);
    MainMenuStrip = menuStrip1;
    MainMenuStrip = menuStrip2;
    Text = "Menuebar";
}
4

1 回答 1

0

我通过调用两个 mainToolStripMenuItems 来解决它...在此之前我试图重载 MainMenuStrip = menuStrip1; 但不可能......但解决方案相当简单:P

menuStrip1.Items.AddRange
(new ToolStripItem[] 
   {     mainToolStripMenuItem,
    mainToolStripMenuItem2 });
于 2013-10-09T08:22:53.790 回答