[Gambas-user] Filtering listbox list
Shannon Kuchler
shannon at inflecto.org
Sun Mar 11 09:32:21 CET 2018
Sorry I didn't explain myself well enough maybe I'll get it right this time.
I'm trying to filter the List of a ListBox based on the text property of a textBox with the results being added to another listbox during a key eventI hope that make more sense
> Using Gambas 3.10 I'm looking for a way to filter the content of a ListBox using TextBox_KeyPress()
>
>
> I know it can be done, but honesty have no idea where to start.
Just to be clear, are you saying that you want to filter the List of a ListBox based on the Text property of a TextBox? (I
actually have to wonder how you know it can be done.)
ListBox has no 'mask' property. So, since ListBox.List is a string array, you would have to:
1. maintain a separate string array,
2. fill the ListBox.List from that original array,
3. on a key event, clear the List and then refill it incrementally from the original array using String[].Find (with Mode=gb.Like).
If you instead are wanting to do incremental searching, you can do that relatively easily by setting the ListBox.Index with
ListBox.Find. But, you'll want to use the KeyRelease event.
[code]
Public Sub Form_Open()
With ListBox1
.List = ["abcd", "abce", "abde", "bcde", "bdef"]
.Mode = Select.Single
End With
TextBox1.SetFocus
End
Public Sub TextBox1_KeyRelease()
ListBox1.Index = ListBox1.Find(TextBox1.Text & "*", gb.Like)
End
[/code]
--
Lee
--------------------------------------------------
This is the Gambas Mailing List:
https://lists.gambas-basic.org/listinfo/user
Search the list:
https://lists.gambas-basic.org/cgi-bin/search.cgi
Hosted by https://www.hostsharing.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20180311/e9af9a95/attachment-0001.html>
More information about the User
mailing list