From 47aa4ae2904b057c6ebadfe7f7bf801b9bb64fef Mon Sep 17 00:00:00 2001 From: lu <99954486@qq.com> Date: 星期四, 03 四月 2025 11:30:13 +0800 Subject: [PATCH] 选择字典 --- DevApp/Gs.DevApp/XtraForm1.cs | 65 ++++++++++++++++++++++++++++++++ 1 files changed, 65 insertions(+), 0 deletions(-) diff --git a/DevApp/Gs.DevApp/XtraForm1.cs b/DevApp/Gs.DevApp/XtraForm1.cs index bf6b785..49e5a3e 100644 --- a/DevApp/Gs.DevApp/XtraForm1.cs +++ b/DevApp/Gs.DevApp/XtraForm1.cs @@ -1,4 +1,8 @@ 锘縰sing DevExpress.XtraEditors; +using DevExpress.XtraTreeList; +using Gs.DevApp.Entity; +using Gs.DevApp.ToolBox; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; @@ -16,6 +20,67 @@ public XtraForm1() { InitializeComponent(); + tlMenu.ContextMenuStrip = contextMenuStrip1; + getTree(); + } + + /// <summary> + /// 璇诲彇鍒楄〃 + /// </summary> + private void getTree() + { + var pgq = new PageQueryModel(1, 999999, "a.type_memo"); + var json = JsonConvert.SerializeObject(pgq); + try + { + var strReturn = + 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 = "typeMemo"; + tlMenu.EndUpdate(); + this.tlMenu.CollapseAll(); + tlMenu.OptionsBehavior.Editable = true; + tlMenu.OptionsBehavior.AllowRecursiveNodeChecking = false; + } + catch (Exception ex) + { + 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("鍒楀悕", "鏂板��"); // 鏇挎崲"鍒楀悕"鍜�"鏂板��"涓哄疄闄呭垪鍚嶅拰鍊� + } } } } \ No newline at end of file -- Gitblit v1.9.3