Treeview: Node.LastNode only works at end of treeview

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 'NOTE: does not exit here, except on "Z"
End If
Next

Thanks,
Dean Slindee
 
C

Cor

"Dean Slindee"
It seems that it is difficult to let this newsgroup work like every other
newsgroup.
This is what Fergus did write at 11:30GMT
-----------------------------------------------
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top