How to allow user to modify data in a table in GUI?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a table and two pushbuttons in GUI. When I click the first button it displays the table. And when I press the second one it displays another table which was created by using the data in the fisrt table. I can allow user to modify the data in the fisrt table. However when I try to display the second table it displays the same result before the modifications were made.
Example:
t1: var1 var2 var3
0 1 3
1 3 2
t2: var1
2
3
I modify the table as:
t1: var1 var2 var3
2 1 1
3 0 1
but the table2 remans the same:
t2: var1
2
3
I have the following piece of code:
handles.data=[handles.C{1} handles.nums];
handles.f = figure;
handles.t = uitable(handles.f,'ColumnEditable', [true,true,true,true]);
handles.t.Data=handles.data;
4 Kommentare
Walter Roberson
am 11 Nov. 2016
Please show the bit about creating the second table and the bit about displaying it.
Antworten (1)
Walter Roberson
am 11 Nov. 2016
That result is expected. Modifying one uitable never affects another uitable, not unless the two have had their contents linked together using linkprop(), or not unless there are callbacks set on the first table that tell it to update the second table as well.
2 Kommentare
Walter Roberson
am 12 Nov. 2016
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
handles.fileName = uigetfile;
fid = fopen(handles.fileName);
C = textscan(fid, '%s %f %f %f');
nums = num2cell([C{2}, C{3}, C{4}]);
data = [handles.C{1} handles.nums];
handles.f = figure;
handles.t = uitable('Parent', handles.f, 'ColumnEditable', [true,true,true,true], 'Data', data);
guidata(hObject, handles);
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
cellArray = get(handles.t, 'Data');
nodeVoltages = circuit(handles.cellArray);
handles.ff = figure;
handles.t2 = uitable('Parent', handles.ff, 'Data', nodeVoltages );
guidata(hObject, handles);
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!