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 CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by