lu
2025-04-03 a9e7dd0920d8d57dc5e3831a8a01a4b81457fb1c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using 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;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace Gs.DevApp
{
    public partial class XtraForm1 : DevExpress.XtraEditors.XtraForm
    {
        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("列名", "新值"); // 替换"列名"和"新值"为实际列名和值
            }
        }
    }
}