uitable オブジェクトにおいて、セルごとに文字列の色を変更することはできますか?
5 views (last 30 days)
Show older comments
uitable オブジェクトの各セルごとにテキストの色を指定する方法を教えてください。
Accepted Answer
MathWorks Support Team
on 17 May 2022
Edited: MathWorks Support Team
on 17 May 2022
R2019b 以降のリリースから uifigure 上に作成されたテーブル(uitable) もしくは uifigure を親とするコンテナーオブジェクト(uipanel や uitabなど)内に作成されたテーブルに対して、uistyle / addStyle 関数を用いて、任意のセルのテキストの色や背景色など、書式を指定することが可能です。
例:
uit = uitable(uifigure, 'Data', randn(3));
[row,col] = find(uit.Data < 0); % 負の値のインデックスを取得
s1 = uistyle;
s1.FontColor = 'red'; % テキストの色を赤色に設定
addStyle(uit,s1,'cell',[row,col]); % スタイルをテーブルに適用
詳細については、各関数のドキュメントをご覧ください。
・uistyle
・addStyle
R2019a 以前のリリースをご利用の場合は、各セルごとに、文字列の色を指定する機能はありません。ForegroundColor プロパティの指定により、一括設定することのみサポートされています。
0 Comments
More Answers (0)
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!