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

2 views (last 30 days)
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 Comments

Sign in to comment.

Accepted Answer

Mohammad Sami
Mohammad Sami on 25 Jun 2021
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 Comments
Rik
Rik on 25 Jun 2021
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>';

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!