V4.0-设置多语言,主窗体的菜单顺序乱了
作者:C/S框架网  发布日期:2013-07-20 15:47:07
  V4.0-设置多语言,主窗体的菜单顺序乱了


感谢孔爷提供图片


贴图图片



解决:替换ModuleManager.cs文件中CreateToolButtons()方法。

C# Code:

/// <summary>
/// 跟据菜单创建Bar按钮
/// </summary>
/// <param name="menuBar">Bar容器</param>
/// <param name="mainMenu">主菜单(各模块主菜单的组合)</param>
public void CreateToolButtons(Bar menuBar, ToolStrip moduleMainMenu)
{
   BarItemLink current = null; int index = 0;
   foreach (ToolStripMenuItem moduleTopMenu in moduleMainMenu.Items)
   {
      if (!moduleTopMenu.Enabled) continue;//顶级菜单荐是禁用状态表示无权限,不创建
      
      //模块主菜单名称(一级菜单)
      BarSubItem menuOwner = new BarSubItem(menuBar.Manager, moduleTopMenu.Text);
      menuOwner.PaintStyle = BarItemPaintStyle.CaptionGlyph;
      menuOwner.Glyph = moduleTopMenu.Image;
      menuOwner.Tag = moduleTopMenu;//设置标记
      menuOwner.ItemClick = new ItemClickEventHandler(menuOwner_ItemClick);
      
      if (current == null)//第一个BarItem
      {
         current = menuBar.ItemLinks.Insert(index, menuOwner);
         current.BeginGroup = true;//第一个菜单项设置分组(小竖线)
         index ;
      }
      else
      {
         current = menuBar.ItemLinks.Insert(index, menuOwner);
         index ;
      }
      
      //递归加载
      foreach (ToolStripItem item in moduleTopMenu.DropDownItems)
      {
         if (item is ToolStripSeparator) continue;//分隔符菜单项,不加载
         if (!item.Enabled) continue;//菜单是禁止使用状态,无权限,不加载
         
         if (item is ToolStripMenuItem && (item as ToolStripMenuItem).DropDownItems.Count > 0)
         {//创建子级
         BarSubItem itemOwner = new BarSubItem(menuBar.Manager, item.Text);
         menuOwner.ItemLinks.Add(itemOwner);
         this.LoadBarSubItems(itemOwner, item as ToolStripMenuItem);
      }
      else
      {
         this.LoadBarButtonItem(menuOwner, item);
      }
   }
}
}

//来源:C/S框架网(www.csframework.com) QQ:1980854898


 


上一篇 下一篇