フィルターのクリア

use of dropdownlist code

2 ビュー (過去 30 日間)
Muazma Ali
Muazma Ali 2021 年 12 月 26 日
コメント済み: Muazma Ali 2021 年 12 月 26 日
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 件のコメント
Image Analyst
Image Analyst 2021 年 12 月 26 日
@Muazma Ali did you overlook my Answer below in the official "Answers" section? Anything wrong with that?
Muazma Ali
Muazma Ali 2021 年 12 月 26 日
No, I saw it for a few min ago. Probably nothing wrong with it, I have just not tried to implement it yet..

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2021 年 12 月 26 日
編集済み: Image Analyst 2021 年 12 月 26 日
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

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by