How to change foreground (text) color of specific cells in a uitable

29 ビュー (過去 30 日間)
Chris
Chris 2019 年 4 月 3 日
コメント済み: farzad 2020 年 4 月 23 日
uit = uitable(figure);
uit.Data = {'row','one';'blank:',' ';'row','three';' ','<--blank'};
uit.ForegroundColor = [1,1,1];
uit.BackgroundColor = [0,0,0;.5,.5,.5];
uit.ColumnEditable = true;
Once the table is generated, I intend on typing information into the blank cells. Is there a way of setting the foreground color of those specific cells to [0,.9,.4], for example? (Or perhaps changing the foreground color of the entire row?) I'm interested in a method of having user added text being a different color than the pre-populate table. Thank you.

回答 (2 件)

Chris
Chris 2019 年 4 月 10 日
I've figured a workaround, for anyone else curious:
<html><font color="#FFDC66">Type your text here :)
Using this html code in a cell allows you to change the text color. You can adjust the html hexadecimal code to whatever color you want, too.
  3 件のコメント
Jan
Jan 2019 年 6 月 18 日
@JessHMann:
uit = uitable(figure);
uit.Data = {'<html><font color="#FFDC66">row', 'one'; ...
'<html><font color="#FFDC00">blank:', ' '; ...
'<html><font color="#FF0066">row', 'three'; ...
' ','<--blank'};
uit.ForegroundColor = [1,1,1];
uit.BackgroundColor = [0,0,0;.5,.5,.5];
farzad
farzad 2020 年 4 月 23 日
is this feasible in App Desginer as well, right in this way ?

サインインしてコメントする。


Tawnly
Tawnly 2019 年 12 月 11 日
This can be accomplished using uistyle and addStyle.
There are examples available in the linked documentation.

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by