Re: Treeview searching

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Tim Baur (trbo20_at_disregard_yahoo.com)
Date: 08/10/04


Date: Tue, 10 Aug 2004 10:36:38 -0700

Tim Baur <trbo20@disregard_yahoo.com> wrote in
news:Xns95418869FCCFDtrbo20hotmailcom@207.46.248.16:

> "Jon" <ruffles_@msn.com> wrote in
> news:10hi0n6tmtgeo53@corp.supernews.com:
>
>> My coworker wrote the following code to search a treeview. It works
>> well enough, except that apparently the text of the nodes is blank
>> until the node has been expanded for the first time (so the searching
>> is only finding things in the top level of the treeview). Is there a
>> way to make this work without having to expand every node of the
>> tree?
>> Thanks for any ideas.
>
> Are you using keys? When you add a node, use the optional parameter,
> Key. All of the tree's nodes are stored as a collection and can be
> referenced with:
>
> tvwTree.Nodes("SOME_KEY")

Sorry, I looked a little more closely at your example. I didn't realize
you were searching the Node's text. Instead of recursing the tree, just do
a For Each ... Next on the Tree's Nodes collection.

See if this doesn't work.

Dim oNode As Node
    
For Each oNode In tvw.Nodes
    iFindPos = InStr(1, SiblingNode.Text, strTerm, vbTextCompare)
    If iFindPos > 0 Then
        oNode.Selected = True
        Exit For
    End If
Next oNode



Relevant Pages

  • Re: How to set all nodes checked = false, on a treeview
    ... (I do have a routine to do that but searching for it has not worked ... If you want to set them to checked = false when you load them, ... >I need to set all nodes on a treeview so that checked=0 ...
    (microsoft.public.dotnet.languages.vb)
  • Treeview Flickering
    ... My treeview is flickering whenever I change the text property of a node. ... I was searching the newsgroups on how to resolve this problem, ...
    (microsoft.public.dotnet.framework.windowsforms)