transfering string from one listbox to another

조회 수: 5 (최근 30일)
Shristi
Shristi 2011년 7월 13일
Hi all, I am trying to transfer string from one listbox to another. Below is the code I found in one of the forum. But it does not seem to work for me at all. Can anyone please help me with this.
list_entry = cellstr(get(handles.listbox1,'String'));
index_selected = list_entry{get(handles.listbox1,'Value')};
choice_listbox1 = list_entry(index_selected);
update_listbox2 = cellstr(get(handles.listbox2, 'String'));
newmenu = [choice_listbox1, update_listbox2];
set(handles.listbox2,'String', newmenu);

답변 (2개)

Walter Roberson
Walter Roberson 2011년 7월 13일
Close!
list_entry = cellstr(get(handles.listbox1,'String'));
index_selected = get(handles.listbox1,'Value'); %changed line
choice_listbox1 = list_entry(index_selected);
update_listbox2 = cellstr(get(handles.listbox2, 'String'));
newmenu = [choice_listbox1, update_listbox2];
set(handles.listbox2,'String', newmenu);
  댓글 수: 1
Shristi
Shristi 2011년 7월 13일
Hi Walter, Thanks for your Answer. But i tried that. It does not seem to work. It transfers the first time, but not after that. Any Idea?

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


Asger
Asger 2013년 8월 26일
Try with newmenu =[update_listbox2; choice_listbox1]
I replaced the , with a ;

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by