| | |
| | | public XtraForm1() |
| | | { |
| | | InitializeComponent(); |
| | | tlMenu.CustomDrawNodeCheckBox += TreeList1_CustomDrawNodeCheckBox; |
| | | tlMenu.ContextMenuStrip = contextMenuStrip1; |
| | | getTree(); |
| | | |
| | | // 初始化TreeList |
| | | |
| | | //tlMenu.BestFitColumns(); |
| | | //tlMenu.EndInit(); |
| | | |
| | | //// 设置复选框显示模式 |
| | | //tlMenu.OptionsBehavior.Editable = true; |
| | | //this.tlMenu.OptionsView.ShowCheckBoxes = true; |
| | | //tlMenu.OptionsSelection.MultiSelect = true; |
| | | ////tlMenu.OptionsSelection.MultiSelectMode = TreeListMultiSelectMode.; |
| | | |
| | | // 添加GetShowCheckBox事件处理器 |
| | | |
| | | tlMenu.OptionsBehavior.Editable = true; |
| | | tlMenu.OptionsSelection.EnableAppearanceFocusedCell = false; |
| | | tlMenu.OptionsSelection.MultiSelect = true; |
| | | tlMenu.OptionsSelection.MultiSelectMode = TreeListMultiSelectMode.CellSelect; |
| | | // this.tlMenu.GetChildAtPoint += new DevExpress.XtraTreeList.GetChildNodeCheckBoxEventHandler(this.treeList_GetChildNodeCheckBox) |
| | | } |
| | | private void TreeList1_CustomDrawNodeCheckBox(object sender, DevExpress.XtraTreeList.CustomDrawNodeCheckBoxEventArgs e) |
| | | { |
| | | // 判断当前节点是否为叶子节点(无子节点) |
| | | if (e.Node.Nodes.Count == 0) |
| | | { |
| | | // 允许绘制复选框(默认行为) |
| | | } |
| | | else |
| | | { |
| | | // 取消绘制复选框 |
| | | e.Handled = true; |
| | | } |
| | | } |
| | | |
| | | // 可选:处理节点展开事件,确保动态加载的子节点生效 |
| | | private void treeList1_BeforeExpand(object sender, BeforeExpandEventArgs e) |
| | | { |
| | | // 若子节点是动态加载的,在此处加载数据 |
| | | // LoadChildNodes(e.Node); |
| | | } |
| | | /// <summary> |
| | | /// 读取列表 |
| | | /// </summary> |
| | | private void getTree() |
| | | { |
| | | var pgq = new PageQueryModel(1, 999999, "a.idx"); |
| | | var pgq = new PageQueryModel(1, 999999, "a.type_memo"); |
| | | var json = JsonConvert.SerializeObject(pgq); |
| | | try |
| | | { |
| | | var strReturn = |
| | | UtilityHelper.HttpPost("", "MenuAction/GetListPage", json); |
| | | UtilityHelper.HttpPost("", "MesDefectTypeManager/GetListPage", json); |
| | | var dd = UtilityHelper.ReturnToTablePage(strReturn); |
| | | var dt = dd.rtnData.list; |
| | | tlMenu.DataSource = dt; |
| | | tlMenu.KeyFieldName = "guid"; |
| | | tlMenu.ParentFieldName = "upGuid"; |
| | | tlMenu.Tag = "name"; |
| | | tlMenu.Tag = "typeMemo"; |
| | | tlMenu.EndUpdate(); |
| | | this.tlMenu.CollapseAll(); |
| | | |
| | | |
| | | tlMenu.OptionsBehavior.Editable = true; |
| | | tlMenu.OptionsBehavior.AllowRecursiveNodeChecking = false; |
| | | } |
| | |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void tlMenu_MouseDown(object sender, MouseEventArgs e) |
| | | { |
| | | if (e.Button == MouseButtons.Right) |
| | | { |
| | | var hitInfo = tlMenu.CalcHitInfo(new Point(e.X, e.Y)); |
| | | if (hitInfo.HitInfoType == HitInfoType.Cell) |
| | | { |
| | | tlMenu.FocusedNode = hitInfo.Node; |
| | | contextMenuStrip1.Show(tlMenu, e.Location); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void toolStripMenuItem1_Click(object sender, EventArgs e) |
| | | { |
| | | if (tlMenu.FocusedNode != null) |
| | | { |
| | | // 删除节点的逻辑 |
| | | tlMenu.DeleteNode(tlMenu.FocusedNode); |
| | | } |
| | | } |
| | | |
| | | private void toolStripMenuItem2_Click(object sender, EventArgs e) |
| | | { |
| | | if (tlMenu.FocusedNode != null) |
| | | { |
| | | // 修改节点的逻辑,例如更改节点值 |
| | | tlMenu.FocusedNode.SetValue("列名", "新值"); // 替换"列名"和"新值"为实际列名和值 |
| | | } |
| | | } |
| | | } |
| | | } |