Find number in uitable

1 回表示 (過去 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 Center および File ExchangeApp Building についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by