Search text in a listbox when pressing a key
16 views (last 30 days)
Hello to all,
I have a listbox containing names ordered in an alphabetical order from which I have to select one in order to complete a configuration.
The thing is there are so many names that scrolling is a very uncomfortable option and I would like to know of it is possible to automatically place the selection when pressing a key from the keyboard (just as you do in Windows when trying to locate a folder/file by pressing the first letter of its name). If it can position itself directly on the desired name after typing the letters it would be great, but I will settle on just positioning on the right letter section (ex.: if the name starts with "S", then I press the key "S" and the listbox positions itself on the first name starting with "S").
Best regards, Ion
Rohit Kudva on 20 Jul 2015
I am assuming that you are using GUIDE for building your GUI. To achieve the functionality you require, you will first have to click on any item in the list box of your interest. Then you can simply type in the name of the item you are looking for and if that item exists, it will be highlighted within the list box.
I hope this helps
Sudhanshu Bhatt on 23 Jul 2015
I am assuming you are using GUIDE in MATLAB R2013a to creating your ListBox. Below are the steps I used to create a ListBox where I was able to select an item by searching for it:
1) On MATLAB command line and type "guide".
2) Drag and create a "ListBox".
3) Double Click on ListBox to open 'Property Inspector'.
4) In the 'String' property , please click the List icon on the left of the pane and fill some default values to appear on the list. For demo purposes I am using : Apple, Ball, Bat, Call, Cat, Dog, Doll.
5) Save the FIG file and that generates a MATLAB script file with callback functions to the figure and ListBox.
6) Run the script using the "Run" option in the MATLAB script or click the "Green Play Button" in the GUIDE GUI Editor.
7) To search for items in the list; First, Click on any random item on the list box and then type the initial letters of the item you want to search. The item if present, will be selected.
I have also attached the code to demonstrate that. This did not give me any issues.
If you are still having trouble then you can submit a service request at the link below:
Hope it helps.