Borrar filtros
Borrar filtros

use of dropdownlist code

2 visualizaciones (últimos 30 días)
Muazma Ali
Muazma Ali el 26 de Dic. de 2021
Comentada: Muazma Ali el 26 de Dic. de 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 comentarios
Image Analyst
Image Analyst el 26 de Dic. de 2021
@Muazma Ali did you overlook my Answer below in the official "Answers" section? Anything wrong with that?
Muazma Ali
Muazma Ali el 26 de Dic. de 2021
No, I saw it for a few min ago. Probably nothing wrong with it, I have just not tried to implement it yet..

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 26 de Dic. de 2021
Editada: Image Analyst el 26 de Dic. de 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

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by