Instead of using single dialog box you can use two uilistboxes.
- One uilistbox should display the list of blanks in the table ‘SampNames’.
- Other uilistbox should be made multiselect and it should display the list of samples in the table ‘SampNames’.
You can refer to the below script which enable to select one blank and multiple samples with the help of uilistboxes. ‘Blanks’ hold the list of blanks and ‘Samples’ hold the list of samples.
function selectlistbox
fig = uifigure('Position',[100 100 350 275]);
% Create text area
txt1 = uitextarea(fig,'Position',[100 90 100 22],'Value','');
txt2 = uitextarea(fig,'Position',[220 70 100 40]);
% Create list box
Blanks = uilistbox(fig,...
'Position',[100 120 100 78],...
'Items',{'First','Second','Third'},...
'ValueChangedFcn', @updateEditField);
% ValueChangedFcn callback
function updateEditField(src,event)
txt1.Value = src.Value;
end
Samples = uilistbox(fig,...
'Position',[220 120 100 78],...
'Items',{'S1','S2','S3'},...
'Multiselect','on',...
'ValueChangedFcn', @updateSelectedSampleField);
function updateSelectedSampleField(src,event)
txt2.Value = src.Value;
end
end
Now once you have the selected items from both the list you can assign or perform any other action over them.
Refer the following documentation to get better understanding of uilistbox: