moving parts of a treeview around

layla

Member
Joined
Apr 26, 2005
Messages
21
Programming Experience
Beginner
I have a mysql table called term in which all the term names have been developed as treenodes on the interface. I now have a term2term table that tells the relationship between each of the nodes on the interface I just created. What I need to do, is

a) to say if something in the treeview equals the name in a field from my mysql table and then to print a message box to confirm this

b) If it does equal then I want to move that treenode that is a match and append it to another part of the tree, whose name I also should have found in the tree.


I have been pursuing this for weeks and would really appreciate any help.

Thanks in advance

I have some code below:

Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click


Dim termtable As DataTable

Dim term2termtable As DataTable

Dim termrow As DataRow

Dim termnode As TreeNode

Dim term2termrow As DataRow

Dim term2termnode As TreeNode

Dim alltext As String

Dim gominerdb As DataSet

Dim gominer2005 As New OdbcConnection: my connection here!

Dim association As New OdbcDataAdapter("SELECT id, term_id, gene_product_id FROM association", gominer2005)
'relevant select statements

gominerdb =
New DataSet

gominer2005.Open()

term2term.Fill(gominerdb, "term2term")

term.Fill(gominerdb, "term")

'Close the connection to the data store; free up the resources

gominer2005.Close()



gominerdb.EnforceConstraints = False





TreeView4.BeginUpdate()

TreeView4.Nodes.Clear()

'termlist = New ArrayList

'childs2 = New ArrayList

termtable = gominerdb.Tables("term")

' loop through all terms to build the term names

For Each termrow In termtable.Rows

termnode =
New TreeNode(termrow.Item(1)) 'selects the term name

'termlist.Add(termrow.Item(1)) 'adds the termrows to the arraylist

TreeView4.Nodes.Add(termnode)

Next termrow



term2termtable = gominerdb.Tables("term2term")



'For Each term2termrow In term2termtable.Rows

'term2termnode = New TreeNode(term2termrow.Item(2) & term2termrow.Item(3)) 'selects term id 1 and term id 2

'If (TreeView4.Nodes.Contains(termlist(term2termrow.Item(2)))) Then



'Dim tn As TreeNode = TreeView4.Nodes.IndexOf(3) 'termlist(term2termrow.Item(2)))

'TreeView1.Nodes.Remove(tn)

'TreeView2.Nodes.Insert(TreeView2.Nodes.Count, tn)

'End If

'Next

TreeView4.EndUpdate()

Call EnumerateTreeNodes()



End Sub

Private Sub EnumerateTreeNodes()

Dim mytreeview As New TreeView

Dim termnode As TreeNode

Dim termrow As DataRow

Dim all As TreeNode

Dim myNodeCollection As TreeNodeCollection = termnode.Nodes

' Check for a node in the collection.

If myNodeCollection.Contains((termrow.Item(1))) Then

label10.Text += "Node2 is at index: " + myNodeCollection.IndexOf((termrow.Item(1)))

End If

label10.Text += ControlChars.Cr + ControlChars.Cr + _

"Elements of the TreeNodeCollection:" + ControlChars.Cr

' Create an enumerator for the collection.

Dim myEnumerator As IEnumerator = myNodeCollection.GetEnumerator()

While myEnumerator.MoveNext()

label10.Text +=
CType(myEnumerator.Current, TreeNode).Text + ControlChars.Cr

End While

End Sub


 
Top Bottom