Showing results for 
Search instead for 
Did you mean: 

Table control: clearing, but properly & other

Go to solution

Hello all! I searched for this topic of clearing a table and some results came up, but this goes deeper...

Clearing the content of a table is simple. Either wire an empty array or use a method. However, if you colored some cells they're not reset by these two ways, so this has to go via extra code where you have to address every single colored cell.


Problem: How many rows/cells to clear? The property NumberOfRows only shows you how many visible rows a table has. The array size of a table when read is always as big as the last one you loaded into the table. What I mean specifically: you would have to store the highest number of rows you ever filled with data to use this number when clearing. 

Side problem, even worse: the table stores the colored cells when you save, so the highest number would have to be saved into a file outside of the application.


I looked through all methods and properties and couldn't find a more elegant way to clear the colored cells. Anybody knows one?

0 Kudos
Message 1 of 9

Other question: tables have a property to adapt the row height automatically. How is this triggered? Writing text that contains a line wrap doesn't do the trick. The help file speaks of multi-line text. What is multi-line text if not one that contains a line wrap or end of line token?

0 Kudos
Message 2 of 9

1) Set ActiveCell to -2,-2 to select all cells.

2) It does work, but you need to activate Multi-Line Input (right-click on the indicator or use a Property Node)


LV 7.1, 2011, 2017, 2019, 2021
Message 3 of 9

2) Ouch! So obvious, but didn't work at first. See the VI nr. 17 below. Found out this is again something where you need to set a selection. The automatic row height furthermore doesn't seem to be a permanent setting, but more of an action you can trigger on the selected cells and then they're auto-sized. Means, you would have to do that over and over.


Seeing all this I wonder what crazy guy designed those classes. This is absolutely insane and way too complicated to use.

0 Kudos
Message 4 of 9

For a test I extended the VI by an express table and a list view. Having the second table wired to all the action in the VI, LabVIEW would still perform the filling/clearing on the first table, but also on the second one that remains empty at then end. Totally crazy.

0 Kudos
Message 5 of 9

Found out that adapting the cell height automatically after either one-line or multi-line text has bee written requires to toggle the property. Means, turn off, then turn on again to trigger the auto-size. Doh! 

0 Kudos
Message 6 of 9
Accepted by topic author MaSta

Just use the -2,-2 as ActiveCell and set the CellBGColor to white when you clear the table.

Table Demo.png

Message 7 of 9

Check out the documentation for "Active Cell":

The magic indices "-1" and "-2" set properties for the heading cell and the whole column/row/table. In case you've been using them: The german help files contain translation errors ("size" instead of "position"), so refer to the english help.


The cell height auto size is a bit wonky. (I see you already found the solution to that one.)

Message 8 of 9

@BasJong53: wow, thanks. Admitted, I never looked at the help page for ActiveCell, as it's self-explaining so far.

@LLindenbauer: also thanks. Yes, the -1 I knew and used before, but -2 was new.

0 Kudos
Message 9 of 9