Moving selected entry from a listbox to another listbox and adding more to the list

3 ビュー (過去 30 日間)
Anthony
Anthony 2015 年 6 月 17 日
回答済み: Anthony 2015 年 6 月 17 日
Hi,
I'm trying to move one entry at a time from a listbox (channelList) to another listbox (importList). I can't figure out how to get it to add multiple entries without overwriting the previous entry. I select a choice on my first listbox, channelList, hit my pushbutton that will move it to the other listbox, importList, it works. I get the correct entry in importList. However, if I need to add another entry to importList, I select one from the first listbox, channelList, hit my move to importList pushbutton, and it will just overwrite the first entry. I don't know how to get around this and make the second list box actually be a list and not just a single entry.
Here is my pushbutton code:
entries = cellstr(get(handles.channelList,'String'))
selected = entries{get(handles.channelList,'Value')}
set(handles.importList,'String', selected)
Thanks ahead of time.
Edit: I tried to use an array with an index but for some reason it still just erases the previous entry...
entries = cellstr(get(handles.channelList,'String'));
selected = entries{get(handles.channelList,'Value')};
selectedList(handles.index) = [{selected}]
handles.index = handles.index + 1
guidata(hObject,handles)
set(handles.importList,'String', selectedList);

採用された回答

Anthony
Anthony 2015 年 6 月 17 日
I got it to work.
function importGUI_OpeningFcn(hObject, eventdata, handles, varargin)
%
handles.index = 1;
guidata(hObject,handles)
%
function addSelected_Callback(hObject, eventdata, handles)
%
entries = cellstr(get(handles.channelList,'String'));
selected = entries{get(handles.channelList,'Value')};
handles.selectedList(handles.index) = [{selected}]
handles.index = handles.index + 1
guidata(hObject,handles)
set(handles.importList,'String', handles.selectedList);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by