ZeeGrid Programming Reference

Cell PRECISION Attribute


Cell PRECISION Attribute

Every ZeeGrid cell has a PRECISION attribute. The cell precision is a numeric value that signifies the number of decimal digits to display when that cell holds numeric data.

By default, non-integer numeric data types are displayed with 2 decimal digits. The precision attribute of a cell can be changed with the ZGM_SETCELLNUMPRECISION message function.

As an example, consider a cell containing a double value of 3.1415926535

By default, this value will display as 3.14 but can be changed at any time to display a different number of decimal digits. Changing a cell's precision attribute does not change the value it holds.

When numeric data is entered by the user by editing the cell contents, a determination is made when the edit function is complete as to whether that new data is text data, or numeric data. If it is determined to be numeric data, and the cell's numeric contents will be displayed with the cell's PRECISION attribute. By default, the PRECISION attribute value is set to 2. Regardless of whether or not the value entered was an integer value or a real number value, it is displayed with the number of decimal places defined by the cell's PRECISION attribute value.

If the cell's PRECISION attribute value is set to 0, the new value will display as an integer value (no decimal digits) regardless of whether the value entered was an integer value or a real number value.

When a numeric value is entered into the grid programmatically with ZGM_SETCELLINT, the PRECISION attribute value is set to 0. When a numeric value is entered into the grid programmatically with ZGM_SETCELLDOUBLE, the double value is displayed with the current PRECISION attribute value for that cell.

A ZeeGrid data cell will hold the actual number entered by the user, regardless of the cell's precision setting.

When loading the ZeeGrid with data programmatically, the programmer has the option of loading the cell as text (ZGM_SETCELLTEXT) and letting ZeeGrid determine if it's numeric or not, or loading the cell as integer (ZGM_SETCELLINT), or double (ZGM_SETCELLDOUBLE).

Each ZeeGrid cell has a single internal numeric "register" of type double. Whether the supplied value is an integer or a real number, it is cast to a double type and stored in the register. The PRECISION attribute is then used to control how the number contained in the cell's numeric register is displayed.

ZeeGrid messages related to the PRECISION attribute:

ZeeGridTMCopyright © 2002-2016 by David Hillard