[Gambas-user] Filtering listbox list
Shannon Kuchler
shannon at inflecto.org
Sun Mar 11 10:33:44 CET 2018
-I think I figured it out
Public Sub TextBox4_KeyRelease()
Dim i As Integer
Dim l As Integer
ListBox6.Clear
If TextBox4.text > "z" Or TextBox4.text < " " Then Return
For l = 0 To ListBox1.Count
Inc i
If ListBox1[i].Text Like TextBox4.Text & "*" Then ' found another
ListBox6.Add(ListBox1[i].Text)
Endif
Next
End
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
--------------------------------------------------
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/329609c1/attachment.html>
More information about the User
mailing list