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

4 visualizzazioni (ultimi 30 giorni)
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 Commenti

Accedi per commentare.

Risposta accettata

Mohammad Sami
Mohammad Sami il 25 Giu 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 Commenti
Joseph Catanese
Joseph Catanese il 25 Giu 2021
So how do i call the html code into the textbox or the sprintf into the html?
Rik
Rik il 25 Giu 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>';

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by