background of editable cells UITABLE
古いコメントを表示
Hi !
I created an uitable with guide and I would like to change the background of editable cells.
I tried to use the HTML code with the method https://www.mathworks.com/matlabcentral/answers/25038-how-to-change-each-cell-color-in-a-uitable , it works for the background, but I can't change the value of my cell anymore.
Any ideas ?
12 件のコメント
Adam Danz
2019 年 7 月 29 日
Check the "ColumnEditable" property values.
Reeny
2019 年 7 月 29 日
Adam Danz
2019 年 7 月 29 日
So the ColumnEditable property has changed and you didn't make that change?
Reeny
2019 年 7 月 29 日
My bet is that "data" is empty
data = {};
data{1,1}
% ERROR: Index in position 1 exceeds array bounds. (r2019a)
Reeny
2019 年 7 月 29 日
Reeny
2019 年 7 月 29 日
Have you verified that 'data' isn't empty? One way of doing that is to put a break at the 3rd line within the conditional (at data{1,1}...) and to see the value of 'data' when the code gets to the break.
Another way of doing that is by printing out the value of 'data' just before that line.
if column == 1
colergen = @(color, text) ['<html><table border=0 width=400 bgcolor=',color,'><TR><TD>',text,'</TD></TR></table></html>'];
data = getappdata(handles.uitable1, 'data')
data %will print to command window
data{1,1} = colergen('#33ffff',(data{1,1}))
set(handles.uitable1, 'data', data);
end
If your error message is "Index exceeds the number of array elements (0)." and that error is comming from the line data{1,1} = colergen..., then either "data" is empty or something's going wrong in your colergen() function.
Reeny
2019 年 7 月 29 日
Adam Danz
2019 年 7 月 29 日
Something's not lining up, could you show the full copy-pasted error message?
From the partial error message you shared, it looks like the error is happening on row=eventdata.... but that line is before the set(handles...) line so that doesn't make sense.
Reeny
2019 年 7 月 29 日
Adam Danz
2019 年 7 月 29 日
Bingo! See answer. Let me know how that turns out.
採用された回答
その他の回答 (1 件)
Reeny
2019 年 8 月 1 日
編集済み: madhan ravi
2019 年 8 月 1 日
カテゴリ
ヘルプ センター および File Exchange で Debugging and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
