Microsoft KB Archive/132534

= FIX: Error Changing Grid s DynamicBackColor & DynamicForeColor =

Article ID: 132534

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition

-



This article was previously published under Q132534



SYMPTOMS
You get the following error when changing the DynamicBackColor and DynamicForeColor in a grid that has a class object added to a column and that class object is the active control with the Sparse Property set to false (.F.):

Expression evaluated to an illegal value



RESOLUTION
Change either the DynamicBackColor or the DynamicForeColor but not both. Or use the default controls that the Form Builder offers.



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem has been fixed in Visual FoxPro 5.0 for Windows.



Steps to Reproduce Problem
 Create a new class named CenterChk based on Container, and store it in Mylib.vcx. In the Class Designer, set the following properties for the container:

Height = 19

Width = 68

BackStyle = 0-Transparent

BorderWidth = 0

 From the Form Controls toolbar, select the check box Control, and place a check box in the container. Set the following Properties for the check box:

BackStyle 0-Transparent

Height = 16

Caption = ""

Width = 14

 With the check box selected, click Center Horizontally and Center Vertically on the Format menu. Then save and close the class. Open the Tastrade.dbc in the VFP\Samples\Mainsamp\Data directory.</li> Create a new form called TestGrid, and add a new property to the form called nCurRec.</li> Using the right mouse button, click the form to bring up the Data Environment. Then using the right mouse button, click the Data Environment. Click Add, and add the Products table.</li> From the Form Controls toolbar, select the Grid control, and add a grid to the form.</li> Using the right mouse button, click the grid, and choose Builder. From the Grid Builder, select the Products table. From the Available Fields, select Product_id, Product_name, and Discontinued.</li> Close the Builder by clicking OK.</li> Set the following Property for the grid:

RowHeight = 19

</li> Using the right mouse button, click the grid, then click Edit.</li> From the Form Controls toolbar, click the View Classes button and choose Add. Select Mylib.vcx from the Open dialog box. From the Form Controls Toolbar, select the CenterChk control, and add it to the Discontinued Column on the grid.</li> Set the following Properties for Column 3 in the grid:

CurrentControl CenterChk1

Width = 68

Sparse = .F.

</li>  Set the following Property for Column 3 CenterChk1 Check1 in the grid: ControlSource = products.discontinued </li>  Add the following code to the Init event of the grid: THISFORM.nCurRec = RECNO THISFORM.Grid1.SETALL('DynamicBackColor',;      'IIF(THISFORM.nCurRec == RECNO, rgb(0,0,128), rgb(255,255,0))',;       'Column') THISFORM.Grid1.SETALL('DynamicForeColor', ;         'IIF(THISFORM.nCurRec == RECNO, rgb(0,0,255), rgb(0,0,0))', ;          'Column') THIS.REFRESH </li>  Add the following code to the AfterRowColChange event of the grid: THISFORM.nCurRec = RECNO THIS.REFRESH </li> Save and run the form.</li></ol>

For more information on creating forms, please see Chapter 9 in the Developer's Guide. For more information on creating classes, please see Chapt1er 10 in the Developer's Guide. And for more information on using controls on a form, please see Chapter 11 in the Developer's Guide.

Keywords: kbbug kbfix kbvfp500fix KB132534

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.