Azzera filtri
Azzera filtri

use of dropdownlist code

2 visualizzazioni (ultimi 30 giorni)
Muazma Ali
Muazma Ali il 26 Dic 2021
Commentato: Muazma Ali il 26 Dic 2021
I have this code.
S={'NH4Cl'; 'MgCl2'; 'CaCl2'; 'KCl'; 'ZnSO4'; 'NaCl'; 'ZnBr2'; 'CH3CO2K';'HCOOK';'HCOONa'; 'CaBr2'};
str={'Choose minimum two salts and maximum three salts available'};
result=listdlg('Promptstring',str, 'ListSize', [100,100], 'ListString', S, 'SelectionMode', 'multiple');
% As I dont want the user to select all salts, I dont want the 'select all' option to come up on the screen. What version of this code can I use so that option doesnt come up..
  5 Commenti
Image Analyst
Image Analyst il 26 Dic 2021
@Muazma Ali did you overlook my Answer below in the official "Answers" section? Anything wrong with that?
Muazma Ali
Muazma Ali il 26 Dic 2021
No, I saw it for a few min ago. Probably nothing wrong with it, I have just not tried to implement it yet..

Accedi per commentare.

Risposte (1)

Image Analyst
Image Analyst il 26 Dic 2021
Modificato: Image Analyst il 26 Dic 2021
I don't see anyway to get rid of hte Select All unless you write your own custom GUI for it. But you can loop until they choose 2 or 3 items:
numSelected = 0;
choices = {'NH4Cl'; 'MgCl2'; 'CaCl2'; 'KCl'; 'ZnSO4'; 'NaCl'; 'ZnBr2'; 'CH3CO2K'; 'HCOOK';'HCOONa'; 'CaBr2'};
promptString = {'Choose salts available (minimum of two and maximum of three)'};
while numSelected < 2 || numSelected > 3
result = listdlg('Promptstring',promptString, 'ListSize', [350,200], 'ListString', choices, 'SelectionMode', 'multiple');
numSelected = length(result);
if isempty(result)
% User clicked cancel. Decide what to do in this case after we exit the loop.
break;
end
if numSelected < 2 || numSelected > 3
warningMessage = 'Please select only 2 or 3 items';
uiwait(warndlg(warningMessage));
end
end
if isempty(result)
return; % Exit the whole program.
end

Categorie

Scopri di più su Mathematics in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by