私は4つのレベルのツリービューを持っています。親、子、孫、曾孫。私の選択したノードは孫レベルです。選択したノードに新しいツリービューを追加するにはどうすればいいですか?
私がしようとしているのは、孫に新しい "Treeview"を作成することです。いいえ、私は "selectednode"(孫)に新しいノードを作成する必要はありません。それは親と同様である孫
ひ孫の子
ひ孫の子 孫孫
た
親 子 孫(新ツリービュー)PARENT:だから、このsomelikeする必要があります母親と父親が離婚し、既存の子どもの配偶者以外の別の配偶者を持つ新たな子どもを持つテーブル。
Private Sub PopulateRootLevel()
' query to find first round of parent
PopulateNodes(dt, JCATreeView.Nodes)
End Sub
Private Sub PopulateNodes(ByVal dt As DataTable, ByVal nodes As TreeNodeCollection)
For Each dr As DataRow In dt.Rows
Dim tn As New TreeNode()
tn.Text = dr("TITLE").ToString()
tn.Value = dr("Parent_ID").ToString()
nodes.Add(tn)
'If node has child nodes, then enable on-demand populating
tn.PopulateOnDemand = (CInt(dr("childnodecount")) > 0)
Next
End Sub
Private Sub PopulateSubLevel(ByVal parentid As Integer, ByVal parentNode As TreeNode)
' query to find children of parent with child node count of parent
da.Fill(dt)
PopulateNodes(dt, parentNode.ChildNodes)
End Sub
Protected Sub TreeView1_TreeNodePopulate(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles TreeView1.TreeNodePopulate
' add a test to determine if this is from TreeView1 or Sub_TreeView1
PopulateSubLevel(CInt(e.Node.Value), e.Node)
End Sub
Protected Sub TreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.SelectedNodeChanged
Dim selected_parent_id As Integer = sender.SelectedNode.value
Parent_to_NEW_TREEVIEW_PopulateSubLevel(selected_parent_id, sender.SelectedNode)
End Sub
Private Sub Sub_TreeView1_PopulateSubLevel(ByVal parent_id As Integer, ByVal parentNode As TreeNode)
' Query to get new children of parents
da.Fill(dt2)
Sub_TreeView1_PopulateNodes(dt2, parentNode.ChildNodes)
End Sub
Private Sub Sub_TreeView1_PopulateNodes(ByVal dt As DataTable, ByVal nodes As TreeNodeCollection)
For Each dr As DataRow In dt.Rows
Dim tn As TreeNode = New TreeNode()
'tn = parentBCNode.Nodes.Add("NEW_PARENT_TREEVIEW")
' query to get child on the new parent treeview
tn.Text = dr("New parent title").ToString()
tn.Value = dr("New_parent_ID").ToString()
nodes.Add(tn)
'If node has child nodes, then enable on-demand populating
tn.PopulateOnDemand = (CInt(dr("childnodecount")) > 0)
Next
End Sub
新しい「ツリービュー」は単なる別のノードです。実際の問題は、新しいノードを追加する必要があるかどうかです。選択したノードの兄弟ですか? –