Reading cell array strings into GUI edit text box

조회 수: 3 (최근 30일)
Stephen
Stephen 2014년 12월 11일
댓글: Stephen 2014년 12월 12일
Quite a simple question today:
I've got a fairly basic GUI with an edit text box. I've got one main block of code in my push button callback. The code produces a cell array of strings and using a loop at the end of the code I want to populate the edit text box with each row respectively of the cell.
So far I have this at the end of my push button callback (could be in completey wrong place)
for zz=1:length(matchescell)
message=matchescell{zz,1};
set(handles.edit10, 'String',message);
end
The only function this has at the moment is to remove the existence of the box on the GUI. I know I'm doing something fundamentally wrong here, there's not much info around looping cell array data into GUIs.
EDIT: I've worked out that the formatting in the strings (line breaks \n) are causing it to not work. I've split the lines up into different columns, so now I need to tell it to do something like this:
set(handles.edit10, 'String',matchescell{v,1} sprintf('\n') matchescell{v,2});
  댓글 수: 1
Geoff Hayes
Geoff Hayes 2014년 12월 11일
Stephen - try avoiding the loop altogether and just set the string with the cell array, ensuring that your edit text box has multiline enabled.

댓글을 달려면 로그인하십시오.

채택된 답변

Geoff Hayes
Geoff Hayes 2014년 12월 12일
Stephen - a very simple example would be to set the edit10 text control to multiline and then try the following example in the button callback
msg = {'hello', 'goodbye', 'seeya', 'ciao'};
set(handles.edit10,'String',msg);
and all four strings will appear one after the other in the control.
  댓글 수: 1
Stephen
Stephen 2014년 12월 12일
Modified this method to suit my problem, thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by