Second, increase, delete tree nodes
Add, delete, modify the node simply in TreeView, just use the NODEs attribute add, remove, etc. It is a big collection, and VS.NET is a nodes property under each Node in the hierarchical. Increase, delete, modify the tree node, which is very different from VS6.0, especially when deleting.
Private Sub ButAdd_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButAdd.Click 'child node is added under the selected node Dim tmpNd As New TreeNode (), NdSel As TreeNode tmpNd.ID = GetNewId () NdSel = TreeView1.GetNodeFromIndex (TreeView1.SelectedNodeIndex) 'selected node tmpNd.Text = "new node" NdSel.Nodes.Add (tmpNd) Dim myRow As DataRow myRow = ds.Tables ( "tree"). NewRow () myRow ( "Node_name") = tmpnd.id myrow ("node_descript") = "new node" & tmpnd.id & "new ndsel.id myrow (" parent_name ") = ndsel.id ds.tables (" Tree "). Rows.Add (myRow) End Sub Private Sub ButDele_Click (ByVal sender As Object, ByVal e As System.EventArgs) Handles ButDele.Click 'delete the selected node Dim idx As String = TreeView1.SelectedNodeIndex () GetNdCol (idx) .Remove ( TreeView1.GetnodeFromindex (IDX)) DIM DV AS New DataView (), Recno As INTEGER DV.TABLE = DS.TABLES ("Tree") DV.RowFilter = "NodeId =" & ndid Dv.delete (0) End Sub Private function GetCol (Byval IDX AS String) As TreenodeCollection 'Nodes Collection Dim CNT AS Integer, i as Integer Dim Tmpnds as Treenode Collection Dim IDXS () AS String IDXS = Split (IDX, ".") CNT = Ubound (IDXS) IF CNT = 0 TMPNDS = TreeView1.nodes else Tmpnds = TreeView1.nodes (cint)). Nodes). Nodes For i = 1 to CNT - 1 tmpnds = tmpnds (cint (idxs (i))). Nodes next endiff n n n e