uitable formatting (cell borders, color,comma style)
조회 수: 18 (최근 30일)
이전 댓글 표시
Hello,
Questions on uitable:
1) how to add cell borders on the table(data area)? I tried to use findjobj, but not sure which one to call in here http://www.mathworks.com/matlabcentral/fileexchange/14317
2) how to add color on column and row header(not the BackgroundColor/ForegroundColor), if it is possible.
3) how to change data format, so instead of 2e+04, I prefer 20,000 (the comma style)
This one already found a reference. http://www.mathworks.com/support/solutions/en/data/1-35XMQ9/?product=ML&solution=1-35XMQ9 And to align numbers in the table, refer to http://www.mathworks.com/matlabcentral/answers/2928.
Anyone knows how to code all that? Thanks in advance!
댓글 수: 0
채택된 답변
Walter Roberson
2012년 8월 13일
You can use HTML in the columnname parameter.
columnname = {'<FONT color="green">Rate</FONT>', ....}
The leading '<HTML>' must be present for this to work.
I do not know that you can affect the cell borders. You could experiment with using HTML for the data cell array (which requires that the entries be strings), but since the HTML affects only one cell at a time, I do not know if you will be able to affect the borders.
댓글 수: 4
Azzi Abdelmalek
2012년 8월 13일
it's just the string which is colored, then if you have string with differents length, you will have different colored width, which is not presentable
추가 답변 (2개)
Babak
2012년 8월 13일
Open the GUI with GUIDE first, then double click on the table. A window named property inspector will open up.
Property inspector for uitable has a few options like "column editable". If you click ont he right side of this option, a new window named "Table Property Editor" opens up.
In the forth pane of this window you can setup the colors.
In the first pane named "columns" you can see the columns you have created (or if you have not yet created any column you can start creating them here) there is a place where it says "Format" where if you click on the optionsyou can change the data type of the data you put in the columns.you can even create a custom data type.
Hope that helps but I don't understand why one needs to add grid in the cells of the table and never heard of it.
댓글 수: 4
Azzi Abdelmalek
2012년 8월 13일
% h=uitable(...)
to set a color
set(t,'BackgroundColor',[.8 .5 .9],'ForegroundColor',[0 1 0]);
%[0 1 0] RGB color
댓글 수: 2
Himanshu Verma
2020년 5월 19일
Zoe Zhang, did you find any solution to the above question you've asked? I need to change the font color of each row with different colors without using 'uistyle' and 'addStyle'. Also, html code doesn't seem to be working with uifigure (works with figure);
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!