필터 지우기
필터 지우기

Remove Items

조회 수: 12 (최근 30일)
Maryam Emad
Maryam Emad 2011년 12월 14일
댓글: Image Analyst 2014년 7월 14일
How I can Remove a specific Items from listbox ??

채택된 답변

Image Analyst
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
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
Maryam Emad 2011년 12월 15일
Thanks a lot "Image Analyst" ..
I try to use your code , it is work good and remove specific items.
But, when I want to delete the last item , listbox was deleted as a whole!!!
Pleas Help me :(
  댓글 수: 8
Jihad Chamseddine
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
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 CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by