TreeView's operation

xiaoxiao2021-03-06  15

///

/// 归 中 中 点 //// /// Node /// BOOL value < / param> private void CheckAllChildNodes (TreeNode treeNode, bool nodeChecked) {foreach (TreeNode node in treeNode.Nodes) {node.Checked = nodeChecked; if (node.Nodes.Count> 0) {// if the current node has a child node Call the recursive function this.checkAllChildNodes (node, nodechecked);}}}

///

/// Toned a certain operator's related authority /// /// permission tree /// module ID private void CallRecursive (TreeView treeView, string [] PopeArray) {TreeNodeCollection nodes = treeView.Nodes; foreach (TreeNode n in nodes) {//n.Checked = true; PrintRecursive (n, PopeArray }}

///

/// recursive call /// /// Node /// Module ID Private Void PrintRecursive (Treenode Treenode, String [] PopeArray) {Foreach (TREENODE TNIONODE.NODES) {FOREACH (Str.Trim (). Tostring () == ((com.js) .Park.dmt.dmtmodule) TN.TAG) .MOD_ID.TRIM (). Tostring ()) {tn.checked = true; tn.parent.checked = true;}}} printrecursive

///

/// Set the tree node background color /// /// /// private void SetTreeBackRecursive (TreeNode treeNode, bool _flag) {foreach (TreeNode tn in treeNode.Nodes) {if (_flag == true) tn.BackColor = System.Drawing.Color.White; else tn.BackColor = System.Drawing. Color.Fromargb ((System.byte) ((240)) ((System.byte) (240)))); SettreeBackRecursive (TN, _FLAG);}}

#region tree node drag private void trv_ParkTree_DragDrop (object sender, System.Windows.Forms.DragEventArgs e) {// get information obtaining source node for "Drag" drag operation string TreeNode sourceNode = this.trv_ParkTree.SelectedNode; string dummy = "temp"; string source_Text = (string) e.Data.GetData (dummy.GetType ()); string target_Text = ""; int source_id = 0; source_Text = source_Text.Substring (source_Text.IndexOf ( ":" ) 1) .Trim (); string soruceNodeType = this.checkNode (sourceNode); TreeNode DragNode = new TreeNode (source_Text); // Create a node DragNode.Tag = sourceNode.Tag; switch (soruceNodeType) // The source node type calculates correlation ID {case "ParkNode": source_id = ((OMTPark) this.trv_ParkTree.SelectedNode.Tag) .PRK_ID; DragNode.ImageIndex = 0; break; case "RootParkNode": source_id = ((OMTPark) this.trv_ParkTree. SELECTEDNODE.TAG) .prk_id; SorucenodeType = "parknode"; Dragnode.ImageIndex = 1; Break; Case "computenode": Source_ID = ((OMTComputer) this.trv_park Tree.SelectedNode.Tag) .COM_ID; DragNode.ImageIndex = 2; break; case "MachineNode": source_id = ((OMTMachine) this.trv_ParkTree.SelectedNode.Tag) .MAC_NO; DragNode.ImageIndex = 3; break; default: break ;} //MessageBox.Show (source_Text "" soruceNodeType); // get the target node information m_Position.X = eX; m_Position.Y = eY; m_Position = trv_ParkTree.PointToClient (m_Position); TreeNode DropNode = this.trv_ParkTree.GetNodeAt (m_position); string targetnodetype = this.checknode (dropnode); target_text =

DropNode.Text.trim (); //messagebox.show (dropnode.text); // Add to item IF titled with this string in the target component (DropNode! = Null && Source_id.toString ()! = "" ) {if ((soruceNodeType == "ComputerNode" && targetNodeType == "RootParkNode") || (soruceNodeType == "ParkNode" && targetNodeType == "ParkNode") || (soruceNodeType == "ComputerNode" && targetNodeType == " Parknode ") || (SorucenodeType ==" Machinenode "&& targetNodeType ==" computerNode ")) {if (source_text == target_text) {MessageBox.show (this," Drag and drop position is not "," Tips ", MessageBoxButtons.ok , MessageBoxIcon.Exclamation); return;} if (targetNodeType == "RootParkNode" && soruceNodeType == "ParkNode") {((OMTPark) sourceNode.Tag) .PPARK_ID = ((OMTPark) DropNode.Tag) .PRK_ID; (( OMTPark) sourceNode.Tag) .store ();} else if (targetNodeType == "ParkNode" && soruceNodeType == "ComputerNode" || targetNodeType == "RootParkNode" && soruceNodeType == "ComputerNode") {((OMTComputer) sourceNode .Tag) .prk_id = ((OMTPARK) DROPNODE.TAG) .prk_id; ((OMTComputer) sourceNode.Tag) .store ();} else if (targetNodeType == "ComputerNode" && soruceNodeType == "MachineNode") {((OMTMachine) sourceNode.Tag) .COM_ID = ((OMTComputer) DropNode.Tag ) .Com_id; (OMTMACHINE) SourceNode.tag) .Store ();} InitloadTree (); //dropnode.nodes.insert(Dropnode.index 1, Dragnode;

// Insert to the target node //this.trv_parktree.selectedNode.Remove ();} else {messagebox.show ("Incorrect drag and drop position", "prompt", MessageBoxButtons.ok, MessageBoxicon.exclamation;}}} priva Void TRV_PARKTREE_DRAGENTER (Object sender, system.windows.Forms.drageventargs e) {// determines whether the data currently drag is a string, if yes, drag the string to copy if the destination component (E.DATA.GETDATAPRESENT DataFormats.Text) {E.Effect = DragDropeffects.move;} else {E.Effect = DragDropeffects.none;}}

private void trv_ParkTree_ItemDrag (object sender, System.Windows.Forms.ItemDragEventArgs e) {// determines whether the right mouse button pressed if (this.trv_ParkTree.SelectedNode == null) {return;} else if (this.trv_ParkTree.SelectedNode. PARENT == NULL) {Return;} else if (e.button == mousebuttons.right) {Return;}

String strient = E.Item.tostring (); // Start "DRAG" Operation // DodragDrop (Stritem, Dragdropeffects.copy | Dragdropeffects.move); DodragDrop (Stritem, Dragdropeffects.Move);}

Private void TRV_PARKTREE_DRAGOVER (Object Sender, System.Windows E) {} #ENDREGON

转载请注明原文地址:https://www.9cbs.com/read-48685.html

New Post(0)