From fa113f04a917e85af84813487f033fb6bc43a5d7 Mon Sep 17 00:00:00 2001
From: lu <123456>
Date: 星期六, 20 九月 2025 15:04:35 +0800
Subject: [PATCH] bug

---
 DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs |   55 +++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 35 insertions(+), 20 deletions(-)

diff --git a/DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs b/DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs
index 5c20efc..87cea74 100644
--- a/DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs
+++ b/DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs
@@ -7,6 +7,7 @@
 using System.Collections.Generic;
 using System.Data;
 using System.Drawing;
+using System.Threading.Tasks;
 using System.Windows.Forms;
 
 
@@ -20,11 +21,20 @@
         public UcDictionarySelect(string _strTitle, string _strWhere, string _strMsg = "")
         {
             InitializeComponent();
-
             lbMsg.Text = _strMsg;
             this.strTitle = _strTitle;
             this.strWhere = _strWhere;
             this.Text = _strTitle;
+            tlMenu.IndicatorWidth = 50;
+            tlMenu.CustomDrawNodeIndicator += (s, ee) =>
+            {
+                if (ee.IsNodeIndicator)
+                {
+                    var index = ee.Node.TreeList.GetVisibleIndexByNode(ee.Node);
+                    ee.Info.DisplayText = (index + 1).ToString();
+                }
+            };
+            getTreeAsync();
             tlMenu.MouseDown += (s, e) =>
             {
                 TreeListHitInfo hitInfo = tlMenu.CalcHitInfo(new Point(e.X, e.Y));
@@ -36,16 +46,20 @@
                         if (node.HasChildren) // 鍙湁褰撹妭鐐规湁瀛愯妭鐐规椂鎵嶈�冭檻灞曞紑鎴栨姌鍙�
                         {
                             if (node.Expanded)
+                            {
                                 node.Collapse();
+                                btnOpen.Text = "鍏ㄩ儴灞曞紑";
+                            }
                             else
+                            {
                                 node.Expand();
+                                btnOpen.Text = "鍏ㄩ儴鏀舵嫝";
+                            }
                         }
                     }
                 }
             };
-            getTree();
             tlMenu.CustomDrawNodeCheckBox += TreeList1_CustomDrawNodeCheckBox;
-            tlMenu.OptionsSelection.EnableAppearanceFocusedCell = false;
             btnIn.Click += (s, e) =>
             {
                 findOrigin(tlMenu);
@@ -62,13 +76,20 @@
                 UpdateParent?.Invoke(this, new UpdateParentEventArgs { DynamicList = list });
                 Close();
             };
-            tlMenu.IndicatorWidth = 50;
-            tlMenu.CustomDrawNodeIndicator += (s, ee) =>
-            {
-                if (ee.IsNodeIndicator)
+            btnOpen.Click += (s, e) => {
+
+                if (btnOpen.Text == "鍏ㄩ儴灞曞紑")
                 {
-                    var index = ee.Node.TreeList.GetVisibleIndexByNode(ee.Node);
-                    ee.Info.DisplayText = (index + 1).ToString();
+                    tlMenu.ExpandAll();
+                    btnOpen.Text = "鍏ㄩ儴鏀舵嫝";
+                    return;
+                }
+
+                if (btnOpen.Text == "鍏ㄩ儴鏀舵嫝")
+                {
+                    tlMenu.CollapseAll();
+                    btnOpen.Text = "鍏ㄩ儴灞曞紑";
+                    return;
                 }
             };
         }
@@ -90,17 +111,10 @@
                 e.Handled = true;
             }
         }
-
-        // 鍙�夛細澶勭悊鑺傜偣灞曞紑浜嬩欢锛岀‘淇濆姩鎬佸姞杞界殑瀛愯妭鐐圭敓鏁�
-        private void treeList1_BeforeExpand(object sender, BeforeExpandEventArgs e)
-        {
-            // 鑻ュ瓙鑺傜偣鏄姩鎬佸姞杞界殑锛屽湪姝ゅ鍔犺浇鏁版嵁
-            // LoadChildNodes(e.Node);
-        }
         /// <summary>
         ///     璇诲彇鍒楄〃
         /// </summary>
-        private void getTree()
+        private async Task getTreeAsync()
         {
             string _where = " and 1=1 and a.type1=1 and " + this.strWhere;
             var pgq = new PageQueryModel(1, 999999, "a.defect_name", "asc", "", _where);
@@ -116,18 +130,17 @@
                 tlMenu.ParentFieldName = "pid";
                 tlMenu.Tag = "defectName";
                 tlMenu.EndUpdate();
-                //  tlMenu.OptionsBehavior.Editable = true;
                 tlMenu.OptionsBehavior.AllowRecursiveNodeChecking = false;
                 tlMenu.BestFitColumns();
-                tlMenu.ExpandAll();
                 tlMenu.CollapseAll();
             }
             catch (Exception ex)
             {
                 MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
             }
+            await Task.Delay(500); // 绛夊緟1000姣锛�1绉掞級
+            tlMenu.CollapseAll();
         }
-
 
         #region MyRegion
 
@@ -190,5 +203,7 @@
             }
         }
         #endregion
+
+      
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3