private void BindMenuTree(TabPage tabpage) { this.ShowWaitting(enuWaitMsgType.BindData); //获取当前选中的tree adtMenu.Nodes.Clear(); Dictionary <string, DevComponents.AdvTree.Node> lstNode = new Dictionary <string, DevComponents.AdvTree.Node>(); Sys_MenuLogic logic = new Sys_MenuLogic(this); List <Sys_MenuResult> lstRst = new List <Sys_MenuResult>(); lstRst = logic.GetMenuTree(new Sys_MenuParam() { }); string beforeCode = "", parentCode = ""; DevComponents.AdvTree.Node beforeNode = null, currentNode = null; foreach (Sys_MenuResult info in lstRst) { #region 产生节点 if (!info.MenuCode.StartsWith(beforeCode) || beforeCode == "") { currentNode = new DevComponents.AdvTree.Node(); currentNode.Image = global::ZNLCRM.UI.Properties.Resources.folder16; currentNode.Text = info.MenuName; currentNode.Name = "trn" + info.MenuID; currentNode.Tag = info.MenuCode; currentNode.ImageExpanded = ZNLCRM.UI.Properties.Resources.folder16; adtMenu.Nodes.Add(currentNode); beforeNode = currentNode; beforeCode = info.MenuCode; } #endregion #region 产生子节点 else { parentCode = info.MenuCode.Substring(0, info.MenuCode.Length - 3); currentNode = new DevComponents.AdvTree.Node(); currentNode.Image = ZNLCRM.UI.Properties.Resources.folder16; currentNode.Text = info.MenuName; currentNode.Name = "trn" + info.MenuID; currentNode.Tag = info.MenuCode; currentNode.ImageExpanded = ZNLCRM.UI.Properties.Resources.folder16; lstNode[parentCode].Nodes.Add(currentNode); } #endregion lstNode.Add(info.MenuCode, currentNode); } HideWaitting(); }
void BindMenuTree() { this.ShowWaitting(enuWaitMsgType.BindData); this.treMenu.Nodes.Clear(); Dictionary <string, DevComponents.AdvTree.Node> lstNode = new Dictionary <string, DevComponents.AdvTree.Node>(); Sys_MenuLogic logic = new Sys_MenuLogic(this); List <Sys_MenuResult> lstRst = new List <Sys_MenuResult>(); lstRst = logic.GetMenuTree(new Sys_MenuParam() { }); string beforeCode = "", parentCode = ""; DevComponents.AdvTree.Node beforeNode = null, currentNode = null, topNode = null; #region 顶级树形菜单节点 topNode = new DevComponents.AdvTree.Node(); topNode.Image = global::ZNLCRM.UI.Properties.Resources.folder16; topNode.Text = "系统菜单目录"; topNode.Name = "trn0"; topNode.Tag = ""; topNode.Checked = true; topNode.Expanded = true; topNode.ImageExpanded = ZNLCRM.UI.Properties.Resources.folder16; this.treMenu.Nodes.Add(topNode); #endregion #region 产生子级节点 foreach (Sys_MenuResult info in lstRst) { #region 产生节点 if (!info.MenuCode.StartsWith(beforeCode) || beforeCode == "") { #region 顶级菜单的顶级 currentNode = new DevComponents.AdvTree.Node(); currentNode.Image = global::ZNLCRM.UI.Properties.Resources.folder16; currentNode.Text = info.MenuName; currentNode.Name = "trn" + info.MenuID; currentNode.Tag = info.MenuCode; currentNode.Expanded = true; currentNode.ImageExpanded = ZNLCRM.UI.Properties.Resources.folder16; topNode.Nodes.Add(currentNode); beforeNode = currentNode; beforeCode = info.MenuCode; #endregion } #endregion #region 产生子节点 else { parentCode = info.MenuCode.Substring(0, info.MenuCode.Length - 3); currentNode = new DevComponents.AdvTree.Node(); currentNode.Image = ZNLCRM.UI.Properties.Resources.folder16; currentNode.Text = info.MenuName; currentNode.Name = "trn" + info.MenuID; currentNode.Tag = info.MenuCode; currentNode.Expanded = true; currentNode.ImageExpanded = ZNLCRM.UI.Properties.Resources.folder16; lstNode[parentCode].Nodes.Add(currentNode); } #endregion lstNode.Add(info.MenuCode, currentNode); } #endregion //隐藏等待窗体 HideWaitting(); this.treMenu.SelectNode(this.treMenu.Nodes[0], DevComponents.AdvTree.eTreeAction.Expand); }