uitable オブジェクトにおいて​、セルごとに文字列の​色を変更することはで​きますか?

17 Ansichten (letzte 30 Tage)
MathWorks Support Team
MathWorks Support Team am 3 Aug. 2016
uitable オブジェクトの各セルごとにテキストの色を指定する方法を教えてください。

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 17 Mai 2022
Bearbeitet: MathWorks Support Team am 17 Mai 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 プロパティの指定により、一括設定することのみサポートされています。

Weitere Antworten (0)

Kategorien

Mehr zu App Designer を使用したアプリ開発 finden Sie in Help Center und File Exchange

Produkte


Version

R2010a

Community Treasure Hunt

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

Start Hunting!