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 个评论
采纳的回答
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 个评论
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 Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!