NumberOfLayers=get(hObject,'value');
N = NumberOfLayers+2;
TH='Input 1';
MO='Input 2';
PR='Input 3';
try
delete(handles.static1(1:end));
delete(handles.edit1(1:end));
delete(handles.edit2(1:end));
delete(handles.edit3(1:end));
delete(handles.static2(1:end));
delete(handles.h_static2);
catch
disp('Create New Static Text box and Edit box');
end
for K = 1 : N
ypos = (N-K+1)*30;
handles.static1(K) = uicontrol('Style', 'text', 'String', sprintf('Layer %#d', K), 'Units', 'Pixels', 'Position', [0 ypos 50 30]);
if K<N
handles.edit1(K) = uicontrol('Style', 'edit', 'String', '', 'Max', 2, 'Units', 'Pixels', 'Position', [50 ypos+5 200 30]);
else
handles.static2(K) = uicontrol('Style', 'text', 'String', sprintf('XXX %#d', ''), 'Units', 'Pixels', 'Position', [50 ypos+5 180 20]);
end
handles.edit2(K) = uicontrol('Style', 'edit', 'String', '', 'Max', 2, 'Units', 'Pixels', 'Position', [250 ypos+5 200 30]);
handles.edit3(K) = uicontrol('Style', 'edit', 'String', '', 'Max', 2, 'Units', 'Pixels', 'Position', [450 ypos+5 200 30]);
end
handles.h_static2 = uicontrol('Style', 'text', 'String', sprintf('%s %s %s', TH, MO, PR), 'Units', 'Pixels', 'Position', [50 (N*30+30) 600 40]);
guidata(hObject,handles);
2 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/482045-how-to-remove-displayed-edit-boxes-when-the-user-changes-the-number-of-inputs-in-gui#comment_750175
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/482045-how-to-remove-displayed-edit-boxes-when-the-user-changes-the-number-of-inputs-in-gui#comment_750175
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/482045-how-to-remove-displayed-edit-boxes-when-the-user-changes-the-number-of-inputs-in-gui#comment_750218
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/482045-how-to-remove-displayed-edit-boxes-when-the-user-changes-the-number-of-inputs-in-gui#comment_750218
Sign in to comment.