display checkbox value in editfield
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Image Analyst
el 20 de Dic. de 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 comentarios
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!