How do I append text to the end of an edit text control?

11 visualizaciones (últimos 30 días)
I am writing a GUI in which a periodically writes to a display area, which I contructed from a multi-line edit uicontrol. I don't know how to append to the end of the existing string

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 28 de Jun. de 2011
There is not functionality in MATLAB 2011a to append text to the end of the current string of an edit text. The workaround is to get the current string, append the desired text to the end, and then set the exit text to have that string. The following example shows the callback for a pushbutton that adds the string "Appended!" to a new line at the end of the existing edit text.
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
currString= get(handles.edit1,'String')
currString{end+1}='Appended!';
set(handles.edit1,'String',currString);

Más respuestas (0)

Categorías

Más información sobre Manage Products en Help Center y File Exchange.

Productos


Versión

R2011a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by