Link two row in a table

3 次查看(过去 30 天)
Cristian Martin
Cristian Martin 2022-8-31
In a GUI a have two tables , trough a button when select a row from the upper table it send to the bottom table like this:
D=get(handles.uitable1,'Data');
Index=get(handles.uitable1,'UserData');
a = D(Index.Indices(:,1), :);
old_data=get(handles.uitable4,'Data');
old_data = array2table(old_data);
new_data = [old_data; a];
set(handles.uitable4, 'Data',new_data);
I have two perform an extra action , so when the user push that button an dialog window ask him if he want to link a new entry from the upper table with an existing one from the second table and if he is agree to force the user to select a row from the second table.
I tried to do something like this:
D=get(handles.uitable1,'Data');
Index=get(handles.uitable1,'UserData');
a = D(Index.Indices(:,1), :);
answer = questdlg('Link entry?', ...
'Atention !', ...
'YES','NO','No thank you');
switch answer
case 'YES'
%%% HERE I DONT KNOW TO FORCE USER TO SELECT A ROW FROM uitable4
D=get(handles.uitable4,'Data');
Index=get(handles.uitable4,'UserData');
variable_for_further_purpose = D(Index.Indices(:,1), :); % This I will use for further_purpose
%%%
old_data=get(handles.uitable4,'Data');
old_data = array2table(old_data);
new_data = [old_data; a];
set(handles.uitable4, 'Data',new_data);
case 'NO'
old_data=get(handles.uitable4,'Data');
old_data = array2table(old_data);
new_data = [old_data; a];
set(handles.uitable4, 'Data',new_data);
end
Thanks !

回答(1 个)

Seth Furman
Seth Furman 2022-9-3
In App Designer and apps created with the uifigure function, uiconfirm is recommended over questdlg because it provides additional customization options.

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品


版本

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by