How to allow user to modify data in a table in GUI?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2016년 11월 11일
Please show the bit about creating the second table and the bit about displaying it.
답변 (1개)
Walter Roberson
2016년 11월 11일
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
Walter Roberson
2016년 11월 12일
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);
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!