treeview help

kirstyb

Member
Joined
Sep 12, 2005
Messages
7
Programming Experience
Beginner
Im working on a treeview with the following structure

accounts
dummy01
00011
00012
00014

dummy02
00012
00015
00018
00019
00025

I need a for loop to go through all account numbers (dummy01, dummy02, dummy04 etc) and find the one that is equal to 'strDummyAccNo' I got as far as the code below but I dont know what to do now. Once an account number is found that is equal to strDummyAccNo, AccNoAttribute is set to the same Account Number.

Need to know how to do the bits in capitals.

Dim intIndexRecon As Integer
Dim intRowCountTV As Integer

intRowCountTV = TVXmlAttributes.Nodes.'HOW MANY CHILD NODES THERE ARE UNDER 'ACCOUNTS' (as integer)
confused.gif


If reconsolidationChk = 1 Then

For intIndexRecon = 0 To intRowCountTV - 1

If TVXmlAttributes.'STRING OF THE INTINDEXRECON (EG "DUMMY02")
ehh.gif
= strDummyAccNo (EG "DUMMY02") Then

AccNoAttribute = strDummyAccNo

End If

Next

End If


Thanks guys
K:confused:
 
Try this...

This should work for you. Change txtInput to your strAcctNo (I took it straight out of code).



VB.NET:
Dim parentnodehold As System.Windows.Forms.TreeNode
Dim childnodehold As System.Windows.Forms.TreeNode
Try
For Each parentnodehold In Me.tvTreeView.Nodes   'Whatever your element's name is.
For Each childnodehold In parentnodehold.Nodes
If childnodehold.Text.Trim = Me.txtInput.Text.Trim Then
'Found
End If
Next childnodehold
Next parentnodehold
Catch ex as <insert appropriate exception>
'I can't think of any possible exceptions
End Try
 
sevenhalo said:
This should work for you. Change txtInput to your strAcctNo (I took it straight out of code).



VB.NET:
Dim parentnodehold As System.Windows.Forms.TreeNode
Dim childnodehold As System.Windows.Forms.TreeNode
Try
For Each parentnodehold In Me.tvTreeView.Nodes   'Whatever your element's name is.
For Each childnodehold In parentnodehold.Nodes
If childnodehold.Text.Trim = Me.txtInput.Text.Trim Then
'Found
End If
Next childnodehold
Next parentnodehold
Catch ex as <insert appropriate exception>
'I can't think of any possible exceptions
End Try


Thanks sevenhalo, didnt think about using For each next rather than for - to next.
Thats helped me loads
 
Back
Top