12-02-2022 02:56 AM - edited 12-02-2022 03:53 AM
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?
Solved! Go to Solution.
12-02-2022 03:39 AM
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?
12-02-2022 03:51 AM
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)
12-02-2022 03:53 AM - edited 12-02-2022 04:09 AM
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.
12-02-2022 03:58 AM
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.
12-02-2022 04:15 AM
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!
12-02-2022 04:17 AM
Just use the -2,-2 as ActiveCell and set the CellBGColor to white when you clear the table.
12-02-2022 04:25 AM - edited 12-02-2022 04:31 AM
Check out the documentation for "Active Cell": https://labviewwiki.org/wiki/Table_class/Active_Cell.Active_Cell_property
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.)
12-02-2022 04:31 AM - edited 12-02-2022 04:32 AM
@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.