我们知道uitable支持 html 内容
的示例类似于我想在这里
看到的,
以解决我在 matlab 中的按钮回调中使用此代码之前提出的问题:
color = uisetcolor;
numberOfClasses = str2num(get(handles.edtNumClass,'String'));
if handles.index == 0
handles.tableData = cell(numberOfClasses,2);
guidata(hObject,handles);
end
handles.index = handles.index+1;
handles.tableData(handles.index,1)=cellstr(get(handles.edtNameClass,'String'));
handles.tableData(handles.index,2)=cellstr('<html><span style="background-color: rgb(color(1,1),color(1,2),color(1,3));"></span></html>');
set(handles.uitable2,'data',handles.tableData);
我的问题是这条线不起作用:
handles.tableData(handles.index,2)=cellstr('<html><span style="background-color: rgb(color(1,1),color(1,2),color(1,3));"></span></html>');
我的意思是当我在 matlab 中打开工作区时,我看到 handle.tableData(handles.indexes,2) 设置为字符串。
但即使此 html 代码未显示为简单字符串,背景颜色也不会改变。细胞没有变化!!!
并且matlab没有给出错误信息!!!
请注意,我什至使用了此代码,但没有任何变化。
handles.tableData(handles.index,2)=cellstr('<html><span style="background-color: #FF0000;"></span></html>');