LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

set precision of table row

I have a table that a user can edit.  I want to force the precision to round to 2 even if the user enters a >2 digit precision number.  I want the table to round their entry if they mess up.  Can I do this with a table property or do I have to sort the data and change them one by one.

 

Thanks

0 Kudos
Message 1 of 4
(2,665 Views)

You could use the value change event in conjunction with the 'update while typing' property. Darren posted a nugget on this recently. Then you convert the string to a number and back to a string and on the table. Not very nice, actually.

Or you could catch the key down? filter events and prevent those characters.

One more way would to overlay the table with a numeric control of said precision (I coded that once with combo boxes), but you might get inconsistent font (moved by a pixel or two).

 

Or you just don't use the table but:

* array of clusters (you can give it a nicer look)

* some kind of spreadsheet (Excel) via ActiveX or .NET

 

Felix

0 Kudos
Message 2 of 4
(2,661 Views)

A table is just a 2D array of strings, so there's no concept of "rounding" for strings. This is something you would need to do yourself.

 

An alternate method would be to use a 2D array of numerics on the front panel. Display the horizontal and vertical scrollbars for the array and hide the digital display. You can set the format properties on the numeric element to do what you want. 

0 Kudos
Message 3 of 4
(2,658 Views)
A table is a 2D string array. You can't force precision and you can't even force the entry to be a numeric.
0 Kudos
Message 4 of 4
(2,652 Views)