Find number in uitable

조회 수: 3 (최근 30일)
john
john 2012년 5월 8일
Hi,
I have uitable, columns and rows are changing, there are not still the same. At first I can insert number only for the first column. If everything is OK, then I can insert number to the next column. If I insert number one or minus one into uitable, and after that if uitable consist more then one "1" or more then "-1", then I need write "Error with 1" or " Error with -1" or "Error with 1 and -1" into edittext, and also I want to set background color to red only for one cell in uitable for last bad inserted number.
Maybe therefore I will need, how to set background color only for one cell.
And maybe I should create any cycle, loop with "for" instruction to searching number "1" and number "-1". In case, if I find number more than one "1" or more than one "-1", I should stop this cycle.
So how can I stop this cycle?
Thank you for help

채택된 답변

Jan
Jan 2012년 5월 8일
You can set the foreground color using the semi-documented method of HTML markup as described in MathWorks solution 1-D782JW. But as soon as you edit the value, the HTML tags are very confusing.
The background color can be set by undocumented Java methods only, see: Undocumented: uitable-cell-colors.
I do not understand what you want to do with the 1's and -1's, but testing the values of a column can be done in the CellEditCallback. If you want a limited list of values only, a popup menu seems to be helpful.
  댓글 수: 1
john
john 2012년 5월 10일
Hi Jan,
is this command OK?
cr = ColoredFieldCellRenderer(java.awt.Color.white);
cr.setCellBgColor(1,1,java.awt.Color(1,1,0)); % yellow

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by