/// <summary> ///Add a People node (with TreeNodeCollection)/// </summary> /// <param name= "TNC" >treenodecollection (node collection for TreeView)</param> /// <param name= "Pid_val" >the value of the parent ID</param> /// <param name= "id" >database ID field name</param> /// <param name= "pid" >Database parent ID field name</param> /// <param name= "text" >database Text field value</param> Public Static voidBind_leaves (DataTable DT, TreeView TNC,stringIdstringPidstringText,contextmenustrip contextMenuStrip1, ImageList imageList1) {DataView DV=NewDataView (DT);//Save a DataTable to DataView for easy filtering of dataTreeNode TN;//Create a node for the TreeView (TreeNode) to add the extracted data to the node foreach(DataRowView DRVinchdv) {tn=NewTreeNode ();//Create a new node (learning name: an instance)Tn. Name = Drv[id]. ToString ();//Value of the node, typically the ID value of the databaseTn. Text = Drv[text]. ToString ();//The text of the node, the textual display of the node foreach(TreeNode nodeinchTNC. Nodes) {if(node. Name = =Drv[pid]. ToString ()) {node. Nodes.Add (TN); Tn. ContextMenuStrip=contextMenuStrip1; Tn. ImageIndex= TN. selectedImageIndex =1; Break; } } //TNC. Nodes[drv[pid]]. Nodes.Add (TN);//Add the node to the TreeNodeCollection (node collection)//bind_leaves (DT, TN. Nodes, TN. Name, ID, PID, text);//Recursive (call this method again and again until the data is taken out) } }