is there a way to change a certain line using sprintf in textbox in app designer

조회 수: 8 (최근 30일)
i have the code set up to display sertain lines in a text box using a sting so they can be added or removed with their certain values but i am also trying to change this color.
% In properties
fpmc='Flatpack MC';
%%
%% in done push buton call back
fpc1=app.FlatpackMcCheckBox.Value;
fpqt1=app.MCQTEditField_2.Value;
jfpt=(50/(app.JoeFlatpackEditField.Value));
dfpt=(50/(app.DavidFlatpackEditField.Value));
nfpt=(50/(app.NickFlatpackEditField.Value));
afp=[jfpt,dfpt,nfpt];
atfp=mean(afp);
ttfp1=atfp;
ttfp2=atfp*2;
ttfp3=atfp*3;
fpqt1t1=fpqt1/ttfp1;fpqt1t2=fpqt1/ttfp2;fpqt1t3=fpqt1/ttfp3;
fpmct1 =[fpqt1t1, fpqt1t2, fpqt1t3]';
fpmct2 =[fpqt1t1/60,fpqt1t2/60,fpqt1t3/60]';
prod=strings(1,14);
p=0;
if fpc1==1&&fpqt1>0
if tth==1
fp1= "%s\t: %.0f %.1f %.1f %.1f"; %s disp Flatpack mc \t(tabs) %.1f is the number value
prod(p+1)=sprintf(fp1,app.fpmc,fpqt1,fpmct2(1),fpmct2(2),fpmct2(3));
p=(p+1);
elseif ttm==1
fp1= "%s\t: %.0f %.2f %.2f %.2f"; % save as above
prod(p+1)=sprintf(fp1,app.fpmc,fpqt1,fpmct1(1),fpmct1(2),fpmct1(3));
p=(p+1);
end
app.ProductTextArea.Value=prod;
the fp1 is the line i want to change the color of to like yellowish green. the entire if statment is multiplied by like 14 for each different item which i want to be another color.
  댓글 수: 6
Rik
Rik 2021년 6월 25일
@Mohammad Sami this looks like an answer to me. Feel free to repost it as such.

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

채택된 답변

Mohammad Sami
Mohammad Sami 2021년 6월 25일
uihtml supports html. So you will need to generate your text in html format. Then you can set this text as HTML Source
a = uihtml;
a.HTMLSource = '<p style="color:#FF0000";>Red paragraph text</p><p style="color:#0000FF";>Blue paragraph text</p>';
  댓글 수: 4
Joseph Catanese
Joseph Catanese 2021년 6월 25일
So how do i call the html code into the textbox or the sprintf into the html?
Rik
Rik 2021년 6월 25일
Like this you mean?
a = uihtml;
a.HTMLSource = [...
'<p style="color:#FF0000";>' sprintf(fp1,app.fpmc,fpqt1,fpmct1(1),fpmct1(2),fpmct1(3)) '</p>',...
'<p style="color:#0000FF";>' sprintf('%.1f',val) '</p>';

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by