Treeview node.LastNode fails

  • Thread starter Thread starter Dean Slindee
  • Start date Start date
D

Dean Slindee

In the code below, a directory of names is being searched. The parent nodes
are the letters "A" thru "Z". Each letter node has n number of children
name nodes under.
The code only works for the letter "Z", but not for the rest of alphabet.
The way I read the documentation, this code should work for all parent
nodes: A thru Z.
Any ideas? This code is in a textbox keyup event.

For Each nodName In nodLetter.Nodes

strPartial = nodName.Text.Substring(0, txtFindArtist.Text.Length)

If nodName Is nodLetter.LastNode Then

Exit For 'does not exit here, except on "Z"

End If

Next



Thanks,

Dean Slindee
 
Not sure if this is your problem but it wont hurt ;p
the code should work if you are searching a specific node (nodLetter) if you
want to search your entire tree you need another for loop around it

for each nodeke in tree1.nodes
...
next nodeke
 
Hi Dean,

I'm not quite sure what you're going to do with these codes. According to
your codes, the last node in the root of tree view is 'Z'. The for loop
will be ended when the 'Z' letter is meet. In For Each statement, you have
to use "For Each nodName As TreeNode In nodLetter.Nodes" instead of "For
Each nodName In nodLetter.Nodes". This tell the compiler that nodName is a
TreeNode object.

Does this answer your question? If anything is unclear, please feel free to
reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "Dean Slindee" <[email protected]>
| Subject: Treeview node.LastNode fails
| Date: Sun, 28 Sep 2003 23:19:13 -0500
| Lines: 27
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 0-1pool36-245.nas14.milwaukee1.wi.us.da.qwest.net
63.156.36.245
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:142068
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| In the code below, a directory of names is being searched. The parent
nodes
| are the letters "A" thru "Z". Each letter node has n number of children
| name nodes under.
| The code only works for the letter "Z", but not for the rest of alphabet.
| The way I read the documentation, this code should work for all parent
| nodes: A thru Z.
| Any ideas? This code is in a textbox keyup event.
|
| For Each nodName In nodLetter.Nodes
|
| strPartial = nodName.Text.Substring(0, txtFindArtist.Text.Length)
|
| If nodName Is nodLetter.LastNode Then
|
| Exit For 'does not exit here, except on "Z"
|
| End If
|
| Next
|
|
|
| Thanks,
|
| Dean Slindee
|
|
|
 
Hi Dean,

I'm a bit puzzled by your code. No - I'm very puzzled by your code.

This is the pseudo-code for your snippet.

For each Letter Node (A to Z)
Get a bit of the name (and ignore it).
If the node is the Z node,
Exit.
Next

It does exactly what you said it does. ;-)

Is this more what you're after?

strArtistPartialName = txtFindArtist.Text
NumChars = strArtistPartialName.Length
For Each nodName In nodLetter.Nodes
strNodePartialName = nodName.Text.Substring(0, NumChars)
If strNodePartialName = strArtistPartialName Then
Exit For
End If
Next

Regards,
Fergus
 
Back
Top