PRB: Decimals Don't Display Properly in GridID: Q135333 The information in this article applies to:
SYMPTOMSNumbers displayed in a grid show four decimal places instead of two.
CAUSEThe Grid.Column.Sparse property is not set to false, and there is no InputMask property defined for the Textbox object of the grid.
RESOLUTIONFor the column that is used to display the numeric data, set the Sparse property to false, and enter a valid input mask for the Textbox object. Note that setting the Sparse property to false can result in some performance degradation.
STATUSThis behavior is by design.
MORE INFORMATIONNumeric fields in a table can have two to nine decimal places. Currency fields have an automatic default of four decimal places. When displaying any numeric or currency information in a grid, it is necessary to set two properties of the grid to limit the display to two and only two decimal places. The first property is the Sparse value. By default, the Sparse property is set to true. According to the information in the Visual FoxPro Help file, the Sparse property specifies whether the CurrentControl property affects all or only the active cell in a Column object. When the Sparse property is set to true, only the column's active cell uses the CurrentControl property setting to accept and display data. The other cells use the default text box. If the Sparse property is set to false, all cells in the Column object will use the CurrentControl property setting to display data. The second property that must be set is the InputMask, which governs how data is entered and displayed in a control. A grid is a combination of several different objects including a text box, so it is necessary to apply some kind of an input mask to the grid text box control. In this situation, a valid input mask would consist of the following:
Setting both of these properties allows the desired level of control when
displaying numeric data in a grid. The setting of the DECIMALS value, such
as SET DECIMALS TO 2, has no effect on the data displayed in the grid.
Steps to Reproduce Behavior1. Create a new form. 2. Add the Orders table to the form's data environment. 3. Drag the table from the data environment to the form. A grid will 4. Run the form.
The data shown in the Order_amt field will display data with four decimal places. Following the steps outlined in this article will result in the data being displayed with two decimal places. Additional reference words: VFoxWin 3.00 decimals currency KBCategory: kbprg kbprb KBSubcategory: FxprgGrid |
Last Reviewed: August 22, 1995 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |