求助关于listbox接收与删除的问题
我做了一个GUI界面,想通过APPEND将左边的内容添加到右边,但是当我选中其中一项时,左边全部添加到了右边,而且 我又应该如何将右边选中项删除而不影响其他项。
function test_listbox( varargin )
if nargin == 0
figureHandle = figure('Tag', 'MyFigure');
uicontrol('Style', 'listbox', 'Tag', 'listbox1', 'Pos', [50 50 100 200], 'String', {'a','b','ccc','ddd','ee'});
uicontrol('Style', 'listbox', 'Tag', 'listbox2', 'Pos', [300 50 100 200], 'String', {'ab','bc','ddd','sad','wd'});
uicontrol('Style', 'pushbutton', 'Tag', 'button1', 'Pos', [190 160 70 25], 'String', 'Append', 'Cal', 'test_listbox(''Append'', gcbo)');
uicontrol('Style', 'pushbutton', 'Tag', 'button2', 'Pos', [190 120 70 25], 'String', 'Delete', 'Cal', 'test_listbox(''Delete'', gcbo)');
handles = guihandles(figureHandle);
guidata(figureHandle,handles);
else
feval(varargin{:});
end
function Append( h )
handles = guidata( h );
value1 = get(handles.listbox1, 'Value');
string1 = get(handles.listbox1, 'String');
value2 = get(handles.listbox2, 'Value');
string2 = get(handles.listbox2, 'String');
string2{end+1} = string1{value1};
set(handles.listbox2, 'String', string2);
function Delete( h )
handles = guidata( h );
value = get(handles.listbox2, 'Value');
string = get(handles.listbox2, 'String');
string(value) = [];
set(handles.listbox2, 'String', string);