MATLAB Function Reference |
Create and display list selection dialog box
Syntax
Description
[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:
Example
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)
See Also
Predefined Dialog Boxes for related functions
linspace | load |
© 1994-2005 The MathWorks, Inc.