1

セルの背景色を設定したい..

何かのようなもの:

ここに画像の説明を入力

RGBカラーと、色を付けたいセルの数があります。

セルの位置は私が書いたものであると想定できます。

私の色はRGBで与えられます:

color = [255 0 0];

10番目のセルに追加したいので、次のように書きました。

S.cell_data(10) = uicontrol('style','text',...
               'units','pix',...
               'Position',[20 70 80 40],...
               'string',color);

スタイルは「テキスト」ではなく、文字列でもありません。

これは私が今しようとしているものです:

S.cell_data(10) = uicontrol('style','text',...
               'units','pix',...
               'Position',[125 70 80 40],...
               'string','fh');

parentColor = get(get(S.cell_data(10), 'parent'), 'color');

set(S.cell_data(num_of_cols+1),'foregroundcolor', [0 0 0], ...
  'backgroundcolor', parentColor);

誰か知ってる?

4

1 に答える 1

2
blue = 255;
green = 0;
red = 0;

rgb_str = strcat('<HTML><BODY bgcolor = "rgb(', num2str(red), ', ', num2str(green), ', ', num2str(blue), ')">green background</BODY></HTML>');

S.cell_data(10) = uicontrol('Style','pushbutton', 'Position',[20 70 80 40], 'String', {rgb_str});
于 2012-10-16T17:46:24.510 に答える