uitableは、matlab のボタンのコールバックでこのコードを使用する前に尋ねた問題を
解決するために、ここで
見たいものと同様の例でhtml コンテンツをサポートしていることがわかります。
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 でワークスペースを開くと、handles.tableData(handles.indexes,2) が文字列に設定されていることがわかります。
このhtmlコードが単純な文字列として表示されていなくても、背景色は変わりません。セルに変更はありません!!!
そしてmatlabはエラーメッセージを出さない!!!
このコードも使用しましたが、変更はありませんでした。
handles.tableData(handles.index,2)=cellstr('<html><span style="background-color: #FF0000;"></span></html>');