GUI: Editting Value in a textbox
조회 수: 1 (최근 30일)
이전 댓글 표시
Good afternoon
Please I need your advice: how do I overwrite text in a textbox without deleting the old data...
i.e is the textbox already contains the letter "a" and I need to add the letter "b" , the first letter won't be deleted....but instead the textbox would contain "ab"
the textbox won't reset unless I manually cleared it...
please help
댓글 수: 0
답변 (1개)
Geoff Hayes
2015년 5월 17일
Nour - you could get the value from the edit text control, then append or concatenate the second character to it, and set the edit text control with the new string. For example,
% get the current string from the edit control
str = char(get(handles.edit1,'String'));
% update the string with the letter 'b'
str = [str 'b'];
% set the text control with the new string
set(handles.edit1,'String',str);
The above assumes that you are using GUIDE to create your GUI and that the edit text control is named (tagged) as edit1.
댓글 수: 1
Walter Roberson
2015년 5월 17일
Note that at least with the original Handle Graphics:
If you try to use a uicontrol KeyPressFcn callback to get access to what the user is typing as they type it, that the String property of the uicontrol will not be updated until the control is activated by pressing Enter.
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!