Search text in a listbox when pressing a key
5 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(2 个)
Rohit Kudva
2015-7-20
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
Sudhanshu Bhatt
2015-7-23
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!