Search text in a listbox when pressing a key

6 vues (au cours des 30 derniers jours)
Ion CANDEL
Ion CANDEL le 9 Juil 2015
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

Réponses (2)

Rohit Kudva
Rohit Kudva le 20 Juil 2015
Hi Ion,
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
- Rohit
  1 commentaire
Ion CANDEL
Ion CANDEL le 21 Juil 2015
Hi Rohit,
Thank you for your reply. I have followed your indications and still it does not work. I am using Matlab R2013a.
Best regards, ION

Connectez-vous pour commenter.


Sudhanshu Bhatt
Sudhanshu Bhatt le 23 Juil 2015
Hi Ion,
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.
Thanks
Sudhanshu Bhatt

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by