Microsoft KB Archive/139865

= FIX: Programmatic Change in Grid Does Not Update ControlSource =

Article ID: 139865

Article Last Modified on 10/15/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition

-



This article was previously published under Q139865



SYMPTOMS
When trying programmatically to change the value in a text box that is contained in a grid, you discover that the underlying data is not updated.



WORKAROUND
To work around the problem, use a REPLACE statement to change the underlying data, and use the REFRESH method to update the grid.



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
 Open the Testdata.dbc database found in the \Vfp\Samples\Data directory. Create a new form. Add the Customer table from the Testdata database to the Data Environment of the form. Add a grid by dragging the Grid icon from the Form Controls toolbar onto the form. Set the RecordSource property of the grid to the Customer table. Add a command button to the form.</li>  Add the following code to the Command1 Click event procedure: thisform.grid1.column2.text1.value='Hello World' thisform.grid1.refresh </li> Save the form as Test.scx, and run it.</li> Click the Command1 button. You will notice that the grid does not have the new value in the Company field.</li></ol>

Place the following code in the Command1 Click event to work around the problem and place the correct value in Grid1: REPLACE (thisform.grid1.column2.text1.controlsource) WITH 'Hello World' thisform.grid1.refresh

Keywords: kbbug kbfix kbvfp500fix kbcode KB139865

-

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

© Microsoft Corporation. All rights reserved.