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에서 Data Import and Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
