我有一个关于将编辑中的数据插入表格的问题。就像现在一样,出现了一个新行,其中包含我在文本框中写入的数据。我的问题是第一行..它是空白的。
提前致谢
function tablerows
% Test dynamic addition of rows
close all
clc
figure
emptyRow = {'','',''};
tableData = emptyRow;
g=uitable('ColumnEditable', true(1,3), ...
'Data',tableData,'CellEditCallback',@editCallback);
uicontrol('style','pushbutton',...
'position' ,[100 0300 100 50],...
'callback', @kort)
w=uicontrol('style','edit',...
'position' ,[400 220 100 30]);
q=uicontrol('style','edit',...
'position' ,[400 320 100 30]) ;
e=uicontrol('style','edit',...
'position' ,[400 120 100 30]);
function kort (hObjects,eventdata)
old=get(g,'data')
newrow={get(q,'string') get(w,'string') get(e,'string')}
new=[old;newrow]
set(g,'data',new)
if get(g,'data')=={'', '' ,''}
set(g,'data',newrow)
else
set(g,'data',new)
end
end
end