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

5 visualizaciones (últimos 30 días)
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);

Respuesta aceptada

Anthony
Anthony el 17 de Jun. de 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);

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by