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

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

 Réponse acceptée

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);

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange

Produits

Version

R2011a

Community Treasure Hunt

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

Start Hunting!

Translated by