listdlg
Displays a dialog box with a list of strings to choose from. This command is only available in the GUI.
Syntax
[R, status] = listdlg('ListString', data...)
[R, status] = listdlg('ListString', data, 'ListSize', size, 'SelectionMode', mode, 'Name', caption, 'InitialValue', value, 'PromptString', prompt, 'OkString', ok, 'CancelString', cancel)
Inputs
- data
- Value for the key 'ListString', giving the list of strings which is displayed in the list box for selection. data can either be a string or a cell array of strings.
- size (optional)
- Value for the key 'ListSize', specifying the minimum size of the list box. size needs to be a two-element vector of integers.
- mode (optional)
- Value for the key 'SelectionMode' argument, specifying whether the selection type is 'single' or 'multiple'. By default, the selection is mode is 'multiple'.
- caption (optional)
- Value for the key 'Name' argument, specifying the caption of the list box.
- value (optional)
- Value for the key 'InitialValue' argument, specifying the entries in the list box which are preselected. The value is a one-based vector of indicies corresponding to the selected entries in data. By default, the first entry is selected.
- prompt (optional)
- Value for the key 'PromptString' argument, specifying the label(s) to be displayed above the list box. prompt can be a string or a cell array of strings.
- ok (optional)
- Value for the key 'OkString' argument, specifying the caption of the 'OK' button, which accepts your selection in the dialog box. The default caption for the button is 'OK'.
- cancel (optional)
- Value for the key 'CancelString' argument, specifying the caption of the 'Cancel' button, which discards your selection in the dialog box. The default caption for the button is 'Cancel'.
Outputs
- R
- The result is a matrix of one-based indicies of the selected entries from the dialog box.
- status
- status specifies how the list dialog is dismissed. The value is 1 if the OK button is clicked and 0 if the dialog box is dismissed by clicking on the Cancel button.
Examples
[R, status] = listdlg('ListString', {'String1', 'String2', 'String3'})
R = [Matrix] 1 x 2
2 3
status = 1
[R, status] = listdlg('ListString', {'Name', 'Address', 'Other'}, 'Name', 'Field Value',
'InitialValue', [1, 2], 'PromptString', 'Values:', 'OkString', 'Select',
'CancelString', 'Clear')
R = 1
status = 1
[R, status] = listdlg('ListString', {'Name', 'Address'}, 'SelectionMode', 'single')
R = [Matrix] 0 x 0
status = 0