Combo Box Filter Example

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Locked
elanorb
Livecode Staff Member
Livecode Staff Member
Posts: 516
Joined: Fri Feb 24, 2006 9:45 am

Combo Box Filter Example

Post by elanorb » Thu Sep 12, 2013 10:28 am

Hi

As requested here is an example of how to filter the list displayed in a combo box. The full list is stored as a custom property of the combo box so it can be referred to as needed.

As the user types the textChanged message is handled, the list is filtered using the filter command to find all the lines that have what the user typed at the start. Then the text(options) property of the combo box is set to the filtered list. The label property is also reset to what the user typed as this updates when the text property is set.

The code is all on the combo box.

Code: Select all

on textChanged
   put the label of me into tFilter
   put the cFullList of me into tList
   
   // Filter the list using what has been typed
   filter tList with (tFilter & "*")
   
   // Reset the options
   set the text of me to tList
   
   // Reset the entry
   set the label of me to tFilter
end textChanged
Please let me know if you have any questions.

Kind regards

Elanor
Attachments
comboFilter.zip
(980 Bytes) Downloaded 508 times
Elanor Buchanan
Software Developer
LiveCode

dbcbos
Posts: 23
Joined: Sun Jun 24, 2012 9:49 am

Re: Combo Box Filter Example

Post by dbcbos » Thu Sep 12, 2013 11:38 am

Thanks Elanor that helped me a lot. I tried using a local variable put that was very slow when filtering. With the custom property it works like a charm now.

Locked

Return to “Summer School 2013”