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

3 vues (au cours des 30 derniers jours)
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);

Réponse acceptée

Anthony
Anthony le 17 Juin 2015
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);

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by