MATLAB: Loading items from listbox1 to listbox2

listbox

I am having 2 listboxes. listbox 1 contains a list of files. I want to select multiple files from listbox1 and want to list them in listbox2. as i double click on any file on listbox1 it should get listed in listbox2.
My problem is..
when i double click a item in listbox1, it gets listed in listbox2. but when i double click the second item in listbox1, in listbox2, it comes in place of the previous item, not as the second item in the list.
i want to list all the items in listbox2 when double clicked from listbox1.
here is what , i am trying
function listbox1_Callback(hObject, eventdata, handles)
get(handles.figure1,'SelectionType'); % If double click if strcmp(get(handles.figure1,'SelectionType'),'open') index_selected = get(handles.listbox1,'Value'); file_list = cellstr(get(handles.listbox1,'String')); % Item selected in list box filename = file_list{index_selected};
set(handles.listbox2,'String',filename)
end
Thank you for suggestions..

Best Answer

Add this:
temp = get(handles.listbox2,'String');
temp{end+1} = filename;
set(handles.listbox2,'String',temp)