Filter löschen
Filter löschen

use of dropdownlist code

2 Ansichten (letzte 30 Tage)
Muazma Ali
Muazma Ali am 26 Dez. 2021
Kommentiert: Muazma Ali am 26 Dez. 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 Kommentare
Image Analyst
Image Analyst am 26 Dez. 2021
@Muazma Ali did you overlook my Answer below in the official "Answers" section? Anything wrong with that?
Muazma Ali
Muazma Ali am 26 Dez. 2021
No, I saw it for a few min ago. Probably nothing wrong with it, I have just not tried to implement it yet..

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 26 Dez. 2021
Bearbeitet: Image Analyst am 26 Dez. 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

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by