필터 지우기
필터 지우기

How I can Remove a specific Items from listbox and get its name into a variable??

조회 수: 2 (최근 30일)
i got the code to delete an item from listbox.... now,,, what if i want to get the name of the deleted item in a variable?? for ex there are 4 images in my listbox... image1.jpg,image2.jpg,image3.jpg and image4.jpg..... i delete image3.jpg... now i want the name image3.jpg in a variable... how to do that... please reply...

채택된 답변

Walter Roberson
Walter Roberson 2012년 10월 27일
By then it is too late. Keep track of the item before you delete it.
  댓글 수: 2
Elysi Cochin
Elysi Cochin 2012년 10월 27일
yes... before deleting i want to save the image name in a variable.. how to do it?? that is ... first i select it from listbox.. then i need to save the image name in variable and then delete... how to do my second step... that is save it ina variable before deleting to show that image is deleted in a msg box... please do reply...
Walter Roberson
Walter Roberson 2012년 10월 27일
curidx = get(hObject, 'Value');
curstrings = get(hObject, 'String');
variable = curstrings{curidx};
curstrings(curidx) = []; %delete it in this list
set(hObject, 'String', curstrings); write new list in
Now the variable named "variable" will hold the string.
msgbox( sprintf('Deleting from list: %s', variable) );

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by