Creating Graphical User Interfaces |
Removing Results from the List Box
The GUI Remove button callback deletes any selected item from the Results list list box. It also deletes the corresponding run data from the handles
structure. When a user clicks on the Remove button, the callback executes the following steps:
String
property by setting each item to the empty matrix []
.
handles
structure.
<empty>
and disables the Remove and Plot buttons (using the Enable
property), if all the items in the list box are removed.
handles
structure (guidata
).
Here is the Remove button callback.
function RemoveButton_Callback(hObject, eventdata, handles) currentVal = get(handles.ResultsList,'Value'); resultsStr = get(handles.ResultsList,'String'); numResults = size(resultsStr,1);% Remove the data and list entry for the selected value
resultsStr(currentVal) =[]; handles.ResultsData(currentVal)=[];% If there are no other entries, disable the Remove and Plot button
% and change the list sting to <empty>
if isequal(numResults,length(currentVal)), resultsStr = {'<empty>'}; currentVal = 1; set([handles.RemoveButton,handles.PlotButton],'Enable','off') end% Ensure that list box Value is valid, then reset Value and String
currentVal = min(currentVal,size(resultsStr,1)); set(handles.ResultsList,'Value',currentVal,'String',resultsStr)% Store the new ResultsData
guidata(hObject, handles)
Running the Simulation from the GUI | Plotting the Results Data |