background of editable cells UITABLE
Afficher commentaires plus anciens
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 commentaires
Adam Danz
le 29 Juil 2019
Check the "ColumnEditable" property values.
Reeny
le 29 Juil 2019
Adam Danz
le 29 Juil 2019
So the ColumnEditable property has changed and you didn't make that change?
Reeny
le 29 Juil 2019
My bet is that "data" is empty
data = {};
data{1,1}
% ERROR: Index in position 1 exceeds array bounds. (r2019a)
Reeny
le 29 Juil 2019
Reeny
le 29 Juil 2019
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
le 29 Juil 2019
Adam Danz
le 29 Juil 2019
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
le 29 Juil 2019
Adam Danz
le 29 Juil 2019
Bingo! See answer. Let me know how that turns out.
Réponse acceptée
Plus de réponses (1)
Reeny
le 1 Août 2019
Modifié(e) : madhan ravi
le 1 Août 2019
Catégories
En savoir plus sur Debugging and Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
