Remove Items
13 次查看(过去 30 天)
显示 更早的评论
How I can Remove a specific Items from listbox ??
0 个评论
采纳的回答
Image Analyst
2011-12-14
You have to get the 'String' value of the listbox, which will be a cell array.
currentItems = get(hListbox, 'String');
Set the row for the item you want to remove equal to[].
newItems = currentItems;
newItems(rowToDelete) = []; % Or something like that - maybe it's {}
Then send the cell array back to the listbox with the
set(hListbox, 'String', newItems)
function.
1 个评论
Walter Roberson
2011-12-14
Note:
if get(hListbox,'ListboxTop') >= min(rowToDelete)
then you will want to set(hListbox, 'ListboxTop') to a different value as otherwise it will point to the wrong place or point past the end of the new list.
更多回答(1 个)
Maryam Emad
2011-12-15
8 个评论
Jihad Chamseddine
2014-7-14
I don't know if you guys are still in this page, but I want to ask you if I want when I remove an item from the listbox so they will be renumbered automatically, can that be done? for example I have items numbered from 1 to 10, so if I delete the item 7, I want that the numbers will be renumbered. hope you can help me guys
Image Analyst
2014-7-14
You're going to have to use something like sscanf() to parse the number out of the line of text. Basically strip off the numbers and rebuild your list from scratch with new numbers.
另请参阅
类别
在 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!