display checkbox value in editfield
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Using App Designer, I want to display the status of a checkbox in an edit field, using a button, but using my code it says that the value has to be numeric. As far as I know is checked = 1, unchecked = 0, which IS numeric. So far I have the following very simple code, where 'CheckboxIN' is the CheckBox and 'CheckboxOUT is the NumericEditField: (this is on the callback of the button)
D = app.CheckboxIN.Value;
app.CheckboxOUT.Value = D;
Is 'Value' the right command to get the status of the checkbox?
Both text editfield and text area doesn't work as well.
0 Kommentare
Antworten (1)
Image Analyst
am 20 Dez. 2017
Edit field (text boxes) take strings, NOT numbers. So in the checkbox callback (not the edit callback), do this
% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of checkbox1
checkboxValue = handles.checkbox1.Value;
handles.edit1.String = sprintf('The checkbox value = %d', checkboxValue);
% Update handles structure
guidata(hObject, handles);
See attached demo.
2 Kommentare
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!