[Gambas-user] How to search for an item in a treeview
Stephen Bungay
sbungay at ...981...
Fri Mar 28 00:19:14 CET 2008
Yes, your original post did not ask for anything to be repopulated..
indeed, nothing has been removed from the treeview so you don;t have to
repopulate it using this method.
Could you be a little more clear on what it is you are trying to
accomplish? We have the find done.. whats with the repopulate?
M0E Lnx wrote:
> OK... I can see how that will find the hits... but I dont see how it
> will re-populate it using only the items that were found.
>
> I guess I must have misphrased that in the first place
>
>
> On 3/26/08, Stephen Bungay <sbungay at ...981...> wrote:
>> Ok try this. It is based on a save routine that I used in an
>> edutainment application I developed about a year ago... I pulled my hair
>> out trying to come up with a good recursive routine to do walk the tree,
>> and failed miserably at it. This treeview did not lend itself well to a
>> recursive walk through... but there is another SIMPLER way, Benoit
>> pointed me in the right direction (Thanks Benoit), and now lets pay it
>> forward.
>>
>> Create a test project with three controls on it. Don't rename the
>> controls, just use the default names. The controls to put on FMAIN are a
>> button, a treeview and a TextArea.
>> Now copy and paste this code into FMain
>>
>> PUBLIC Y AS String
>>
>> PUBLIC SUB Form_Open()
>>
>> WITH TreeView1
>> .Add("A", "Item A")
>> .Add("A1", "Item A1",, "A")
>> .Add("B", "Item B")
>> .Add("B1", "Item B1",, "B")
>> .Add("B1.1", "Item B1.1",, "B1")
>> .Add("C", "Item C")
>> .Add("D", "Item D")
>> .Add("D1", "Item D1",, "D")
>> .Add("E", "Item E")
>> END WITH
>>
>> END
>>
>> PUBLIC SUB Button1_Click()
>> WalkTree(TreeView1)
>> END
>>
>>
>> PRIVATE SUB WalkTree(pTreeView AS TreeView)
>> DIM sText AS String
>>
>> pTreeView.MoveFirst()
>>
>> REPEAT
>> sText = sText & pTreeView.Item.Key & ", " & "'" &
>> pTreeView.Item.Text & "'" & "\n"
>> pTreeView.Item.Expanded = TRUE
>> UNTIL pTreeView.MoveBelow()
>>
>> TextArea1.Text = sText
>>
>> END
>>
>>
>> When you push the button it will iterate down through the tree and
>> push the text of each node (and it's key) to a string, After the tree
>> has been 'walked' the string will be dumped to the Text area.
>> Use this to do a search on each ode as you come to it.
>> Job done.
>>
>> Steve.
>>
>>
>> M0E Lnx wrote:
>> > I have a treeview populated with lots of entries... I'm trying to
>> > provide a function that would search within the contents of that
>> > treeview for a specific string.
>> > Can anyone think of a way to do that?
>> >
>> > I've been trying the FIND method in the treeview, but it's quite
>> > different from other find methods...
>> >
>>
>>> -------------------------------------------------------------------------
>> > Check out the new SourceForge.net Marketplace.
>> > It's the best place to buy or sell services for
>> > just about anything Open Source.
>> > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
>> > _______________________________________________
>> > Gambas-user mailing list
>> > Gambas-user at lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/gambas-user
>> >
>>
>>
>> -------------------------------------------------------------------------
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services for
>> just about anything Open Source.
>> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list