User`s guide

Examples: Program GUI C omponents
Ctrl+V –Paste
Ctrl+H Delete last character
Ctrl+A Select all
List Box
When the list box Callback callback is triggered, the list box Va lue property
contains the index of the selected item, where
1 corresponds to the first item
in the list. The
String property contains the list as a cell array of strings.
This example retrieves the selected string. Note that it is necessary to convert
the value of the
String property from a cell array to a string.
function listbo x1_C allback(hObject,eventda ta)
index_selected = get(hObject,'Value');
list = get(hObject,'String');
item_selected = list{index_selected}; % Convert from cell array
% to string
hObject
is the handle of the component for which the event was triggered.
You can also select a list item programmatically by setting the list box
Value
property to the index of the desired item. For example,
set(lbh,'Value',2)
selects the second item in the list box with handle lbh.
Trigger Callback Execution. MATLA B software executes the list box
Callback callback after the mouse button is released or after certain key
press events:
The arrow keys change the
Value property, trigger callback executio n, and
set the figure
SelectionType property to normal.
The Enter key and space bar do not change the
Value property, but trigger
callback execution and set the figure
SelectionType property to open.
If the user double-clicks, the callback executes after each click. the software
sets the figure
SelectionType property to normal on the first click and to
12-23