2012-09-10 79 views

回答

2

只需加載您從DB想要的數據,選擇哪些用戶必須看到,
然後把你想要的MenuStrip中是(面板爲例)
,然後使用類似的容器:

List<string> menuItems = LoadUserMenuItems(); 
     ContextMenuStrip menu = new ContextMenuStrip(); 
     menu.Dock = DockStyle.Fill; 
     foreach (var menuItem in menuItems) 
     { 
      MenuItem item = new MenuItem(menuItem); 
      item.Text = menuItem; 
      item.Click += new EventHandler(item_Click);// item_click is event handler name 
      // item.MenuItems.Add(); you could use this to add sub items 
     } 

     panel1.Controls.Add(menu); 

但請您下一次表現出一定的努力

2

您可以創建表到SQL:

CREATE TABLE [dbo].[MenuItems] 
(
[MenuID] [int] IDENTITY(1,1) NOT NULL, 
[MenuTitle] [nvarchar](50) NOT NULL, 
[MenuIdParent] [int] NULL, 
[MenuEventHandler] [nvarchar](50) NULL, 
[MenuLanguageID] [int] NOT NULL 
) ON [PRIMARY] 
GO 
ALTER TABLE [dbo].[MenuItems] ADD CONSTRAINT [DF_MenuItems_MenuLanguageID] DEFAULT ((1)) FOR [MenuLanguageID] 
GO 
相關問題