how to display whole text in dropdownlist?

1 view (last 30 days)
Muazma Ali
Muazma Ali on 26 Dec 2021
Answered: Image Analyst on 26 Dec 2021
Hi
I have this code;
S={'NH4Cl'; 'MgCl2'; 'CaCl2'; 'KCl'; 'ZnSO4'; 'NaCl'; 'ZnBr2'; 'CH3CO2K';'HCOOK';'HCOONa'; 'CaBr2'};
str={'Choose salts available, minimum two and maximum three'};
result=listdlg('Promptstring',str, 'ListSize', [100,100], 'ListString', S, 'SelectionMode', 'multiple');
% I dont understand why the str is not showing the whole text on the screen

Answers (2)

Voss
Voss on 26 Dec 2021
It is because you specify a 100 pixel by 100 pixel listbox, and str is too long to fit in that amount of space. You can either specify a larger listbox or use a cell array of character vectors or both, e.g.:
S={'NH4Cl'; 'MgCl2'; 'CaCl2'; 'KCl'; 'ZnSO4'; 'NaCl'; 'ZnBr2'; 'CH3CO2K';'HCOOK';'HCOONa'; 'CaBr2'};
str={'Choose salts available,' 'minimum two and' 'maximum three'};
result=listdlg('Promptstring',str, 'ListSize', [150,100], 'ListString', S, 'SelectionMode', 'multiple');

Image Analyst
Image Analyst on 26 Dec 2021
Try increasing the size of the list window:
S={'NH4Cl'; 'MgCl2'; 'CaCl2'; 'KCl'; 'ZnSO4'; 'NaCl'; 'ZnBr2'; 'CH3CO2K';'HCOOK';'HCOONa'; 'CaBr2'};
str={'Choose salts available, minimum two and maximum three'};
result=listdlg('Promptstring',str, 'ListSize', [300,200], 'ListString', S, 'SelectionMode', 'multiple');

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!