1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Private m_arr As New ArrayList
Private m_str As New StringBuilder
Public Sub BuildTree()
Dim dt As DataTable = m_queryLinks.GetAllQueries()
For Each row As DataRow In dt.Rows
m_arr = New ArrayList
m_str.Append(row("QueryName").ToString & "->")
m_arr.Add(CInt(row("QueryId")))
BuildSubTree(m_queryLinks.GetQueries2(CInt(row("QueryId"))))
m_str.Append(vbCrLf)
Next
Me.RichTextBox1.Text = m_str.ToString
End Sub
Public Sub BuildSubTree(ByVal dt As DataTable)
Dim stopLoop As Boolean = False
If dt.Rows.Count > 0 Then
For Each row As DataRow In dt.Rows
For Each i As Integer In m_arr
If CInt(row("QueryId")) = i Then stopLoop = True
Next
If Not stopLoop Then
m_str.Append(row("QueryName").ToString & "->")
m_arr.Add(CInt(row("QueryId")))
BuildSubTree(m_queryLinks.GetQueries2(CInt(row("QueryId"))))
End If
Next
End If
End Sub |