MATLAB Function Reference Previous page   Next Page

Create and display list selection dialog box



[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:

Cell array of strings that specify the list box items.
String indicating whether one or many items can be selected: 'single' or 'multiple' (the default).
List box size in pixels, specified as a two-element vector [width height]. Default is [160 300].
Vector of indices of the list box items that are initially selected. Default is 1, the first item.
String for the dialog box's title. Default is ''.
String matrix or cell array of strings that appears as text above the list box. Default is {}.
String for the OK button. Default is 'OK'.
String for the Cancel button. Default is 'Cancel'.
Uicontrol button height, in pixels. Default is 18.
Frame/uicontrol spacing, in pixels. Default is 8.
Frame/figure spacing, in pixels. Default is 8.


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.

See Also


Predefined Dialog Boxes for related functions

Previous page  linspace load Next page

© 1994-2005 The MathWorks, Inc.