| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
[Selection,ok] = listdlg('ListString',S)
[Selection,ok] = listdlg('ListString',S) creates a modal dialog box that enables you to select one or more items from a list. Selection is a vector of indices of the selected strings (in single selection mode, its length is 1). Selection is [] when ok is 0. ok is 1 if you click the OK button, or 0 if you click the Cancel button or close the dialog box. Double-clicking on an item or pressing Return when multiple items are selected has the same effect as clicking the OK button. The dialog box has a Select all button (when in multiple selection mode) that enables you to select all list items.
Inputs are in parameter/value pairs:
Parameter | Description |
|---|---|
| 'ListString' | Cell array of strings that specify the list box items. |
| 'SelectionMode' | String indicating whether one or many items can be selected: 'single' or 'multiple' (the default). |
| 'ListSize' | List box size in pixels, specified as a two-element vector [width height]. Default is [160 300]. |
| 'InitialValue' | Vector of indices of the list box items that are initially selected. Default is 1, the first item. |
| 'Name' | String for the dialog box's title. Default is ''. |
| 'PromptString' | String matrix or cell array of strings that appears as text above the list box. Default is {}. |
| 'OKString' | String for the OK button. Default is 'OK'. |
| 'CancelString' | String for the Cancel button. Default is 'Cancel'. |
| 'uh' | Uicontrol button height, in pixels. Default is 18. |
| 'fus' | Frame/uicontrol spacing, in pixels. Default is 8. |
| 'ffs' | Frame/figure spacing, in pixels. Default is 8. |
Note A modal dialog box prevents the user from interacting with other windows before responding. For more information, see WindowStyle in the MATLAB Figure Properties. |
This example displays a dialog box that enables the user to select a file from the current directory. The function returns a vector. Its first element is the index to the selected file; its second element is 0 if no selection is made, or 1 if a selection is made.
d = dir;
str = {d.name};
[s,v] = listdlg('PromptString','Select a file:',...
'SelectionMode','single',...
'ListString',str)

dialog, errordlg, helpdlg, inputdlg, msgbox, questdlg, warndlg
Predefined Dialog Boxes for related functions
![]() | list (RandStream) | listfonts | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |