LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

delete row from table programatically

I have a table which contains 10 columns and a max of 100 rows. Each time a new row is generated, I compare each value to a set of limits. If the value is within range, I set the cell color to black. If the value is out of range, I set the cell text color to red. There does not appear to be any way to set the color of the text independant of the cell.
 
The above works just fine until I fill up the table. If the number of rows exceeds my limit, I read the contents of the table, delete the values in the first row of the array, and write the correctly-sized data back to the table. At this point, the new rows appear to stop changing colors, and the color changes made to old rows stay where they are, rather than moving up.
 
This is 'correct' preformance, in that the code is doing exactly what I told it to do. It is not, however, doing what I want it to do, and I have been unable to find a way to make it work. The easiest solution would be to actually delete the row, rather than delete the data, but i cannot find any way to do that programatically. I *can* delete a row by right-clicking and selecting Data Operations -> Delete Row, but this method has the same problem I described above.
0 Kudos
Message 1 of 5
(4,696 Views)


@BobChuck wrote:
There does not appear to be any way to set the color of the text independant of the cell.

There is a cell background property, as well as a text color property. I see you're on 6.1, so this might not be the case though.

As for your main problem. First of all, good description of exactly what issue you are experiencing. I'm on 8.2 and when I right click a cell and select "delete row," it behaves how you want it, the cell below with red text moves up. There is no delete row method to do this though, and wiring a new array of data with the row deleted won't change any colors. The only suggestion I can give you is to do what you want programatically. You'll have to loop through the entire table and either check each value against your limits to set the color, or copy the color from the cell below so the colors move up with the rows. Depending on the size of your table and frequency of adding new rows, this might be costly, but it shouldn't be too bad.

0 Kudos
Message 2 of 5
(4,689 Views)

Well, thats part of the problem...  retesting the out-of-bounds limits every time is not really an option, as the limits might change between rows. The same value in the same column might need to be red in one row and black in another.

I don't want to keep track of the limits for each row; one of the reasons I change the color of the text is to provide a rough summary of the limits at the time of row addition. Also, it seems ridiculous that I should have to create and manage a second, larger table just to make sure the first table has the correct COLORS.

0 Kudos
Message 3 of 5
(4,686 Views)
I see what you mean. That's why I also suggested a second option. When a new row is added, delete the top row from the array. Now, go through each cell and set the color to the color of the cell below it. When you get to the last row, check the value and set the color according to the limits. There will never be a way to have colors follow values in a table just by updating the array that is wired to it, and there shouldn't be. The table doesn't know what the last value was, it can't compare it and figure out which row was deleted. It's only a way to display an array.
0 Kudos
Message 4 of 5
(4,682 Views)

hmm.... that could work. I missed the secondsuggestion when I read your post the first time. i wil ltry that tomorrow and report.

Thank you.

0 Kudos
Message 5 of 5
(4,674 Views)