记录 C# WinFrom 开发,左边菜单功能升级



最近晚上无事,把之前自己做的系统重新改造。第一步从菜单开始看上去高级很多。独立开发者的不容易。

主要用到 NavBarControl,TreeList dockPanel

private void AddLeftMarItem()

{

NavBarControl nbcMenu = this.navBarControl1;

// nbcMenu.Items.Clear();

nbcMenu.GroupExpanded += new NavBarGroupEventHandler(navBarControl1_NavBarGroupExpanded);

//清空组

nbcMenu.Groups.Clear();

Image image = Properties.Resources.application_side_boxes;

nbcMenu.Dock = DockStyle.Fill;

DataTable dtmenu = DBHelper.GetDB(dsmenu.Tables[0], "parentid='_8BB091A2-E3F7-4389-9D43-9AB8F4216236'", "number");

int c = 0;

foreach (DataRow dr in dtmenu.Rows)

{

NavBarGroupControlContainer container = new NavBarGroupControlContainer();

nbcMenu.Controls.Add(container);

var tvMenu = new treeview();

tvMenu.NodeMouseClick += new TreeNodeMouseClickEventHandler(treeView1_NodeMouseDoubleClick);

tvMenu.BorderStyle = BorderStyle.None;

tvMenu.BackColor = this.dockPanel1.BackColor;

tvMenu.Dock = DockStyle.Fill;

tvMenu.HideSelection = true;

tvMenu.ShowLines = true;

tvMenu.ImageList = imageList1;

container.Controls.Add(tvMenu);

AddTreeMenu(dr["menuid"].ToString().Trim(), (TreeNode)null, (treeview)tvMenu);

NavBarGroup nbGroup1 = new NavBarGroup();

nbGroup1.Name = dr["menuid"].ToString();

nbGroup1.Caption = dr["menu"].ToString();

nbGroup1.SmallImage = image;

nbGroup1.LargeImage = image;


if (c == 0)

{

nbGroup1.Expanded = true;

}


nbGroup1.GroupClientHeight = nbcMenu.Height;

nbGroup1.GroupStyle = NavBarGroupStyle.SmallIconsText;

nbGroup1.ControlContainer = container;

nbcMenu.Groups.Add(nbGroup1);

c++;


}


}

版权声明:

作者: freeclashnode

链接: https://www.freeclashnode.com/news/article-492.htm

来源: FreeClashNode

文章版权归作者所有,未经允许请勿转载。

免费节点实时更新

热门文章

最新文章

归档