コード例 #1
0
ファイル: GU.cs プロジェクト: tancfeng/YZ_WinForm
 /// <summary>
 /// Sets the text for the specified control in multithreading circumstances.
 /// </summary>
 /// <param name="control"></param>
 /// <param name="text"></param>
 public static void SetTreeNode(TreeView control, TreeNodeCollection val, String strc)
 {
     if (control != null)
     {
         string[] arrls = strc.Split(new char[] { '|' });
         if (control.InvokeRequired)
         {
             SetTreeNodeSafe scts = new SetTreeNodeSafe(SetTreeNode);
             control.Invoke(scts, new Object[] { control, val, strc });
         }
         else
         {
             if (String.IsNullOrEmpty(strc) == true)
             {
                 for (int i = 0; i < val.Count; i++)
                 {
                     control.Nodes.Add(val[i]);
                 }
             }
             else
             {
                 TreeNode pnode = null;
                 Int32    ik    = 0;
                 foreach (var item in arrls)
                 {
                     if (ik == 0)
                     {
                         pnode = control.Nodes[SRLibFun.StringConvertToInt32(item)];
                     }
                     else
                     {
                         pnode = pnode.Nodes[SRLibFun.StringConvertToInt32(item)];
                     }
                     ik++;
                 }
                 for (int i = 0; i < val.Count; i++)
                 {
                     pnode.Nodes.Add(val[i]);
                 }
             }
             control.ExpandAll();
         }
     }
 }
コード例 #2
0
ファイル: GU.cs プロジェクト: tancfeng/YZ_WinForm
 /// <summary>
 /// Sets the text for the specified control in multithreading circumstances.
 /// </summary>
 /// <param name="control"></param>
 /// <param name="text"></param>
 public static void SetTreeNode(TreeView control, TreeNodeCollection val, String strc)
 {
     if (control != null)
         {
             string[] arrls = strc.Split(new char[] { '|' });
             if (control.InvokeRequired)
             {
                 SetTreeNodeSafe scts = new SetTreeNodeSafe(SetTreeNode);
                 control.Invoke(scts, new Object[] { control, val,strc });
             }
             else
             {
                 if (String.IsNullOrEmpty(strc) == true)
                 {
                     for (int i = 0; i < val.Count; i++)
                     {
                     control.Nodes.Add(val[i]);
                     }
                 }
                 else
                 {
                     TreeNode pnode = null;
                     Int32 ik = 0;
                     foreach (var item in arrls)
                     {
                         if (ik == 0)
                         {
                             pnode = control.Nodes[SRLibFun.StringConvertToInt32(item)];
                         }
                         else
                         {
                             pnode = pnode.Nodes[SRLibFun.StringConvertToInt32(item)];
                         }
                         ik++;
                     }
                     for (int i = 0; i < val.Count; i++)
                     {
                         pnode.Nodes.Add(val[i]);
                     }
                 }
                 control.ExpandAll();
             }
         }
 }