MATLAB在uicontrol单元格中设置背景色 [英] MATLAB set background color in a cell of uicontrol

查看:448
本文介绍了MATLAB在uicontrol单元格中设置背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在单元格中设置背景颜色.

I want to set a background color in a cell..

类似的东西

所以我有RGB颜色和要着色的单元格数量.

so I have the RGB color and the number of cell I want to color.

您可以假定单元格的位置就是我写的.

you can assume that the position of the cell is what I wrote.

我的颜色由RGB给出

color = [255 0 0];

我想在第10个单元格中添加它,所以我写了类似的内容:

I want to add it in the 10th cell, so I wrote something like:

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

但是样式不是'text',也不是字符串.

but the style is not 'text' and it is no a string.

这就是我现在正在尝试的内容:

this is what I'm trying right now:

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);

有人知道吗?

推荐答案

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});

这篇关于MATLAB在uicontrol单元格中设置背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆