RecordSource property is not set back to itself.
The following command will refresh the grid properly if a SELECT-SQL is run to rebuild the cursor, but if the column or header properties of the grid have been customized, these customized changes will be lost and the column and header properties of the grid will change back to their default settings:
Steps to Reproduce Behavior
- Open the Customer.dbf table located in the \Vfp\Samples\Data directory, and create a form called GridForm.
- Place the following code in the Load event of the form:
SELECT cust_id, city, country FROM customer INTO CURSOR Temp1
SELECT cust_id, city, country FROM customer WHERE country = "" ;
INTO CURSOR Temp2
- Place the following code in the Destroy event of the form:
- Place a grid on the form, and give the grid the following property settings:
- Change the caption of the grid1.Column1.header1 to Customer Id and the Column1 Width property to 100.
- Add a text box to the form.
- Add a command button, and place the following code in its Click event:
THISFORM.GRID1.RECORDSOURCE = "Temp2"
SELECT cust_id, city, country FROM customer ;
WHERE country = Thisform.text1.value ;
INTO CURSOR Temp1
THISFORM.GRID1.RECORDSOURCE = "Temp1"
- Run the Form. Type Spain in the text box, and then click the command button. The grid should display all records where the country field is equal to Spain. Note that the name of the header of column 1 stays the same and the width of the column doesn't change. By changing the RecordSource of the grid to the cursor called Temp2, the properties of the columns and headers are not reset when the Temp1 cursor is rebuilt.
- Change the two THISFORM.GRID1.RECORDSOURCE lines in the Click event of the command button into comments and add the following as the last line of code:After running the form, typing a country name in the text box, and clicking the command button, note that the column name changes and the width is smaller.
THISFORM.GRID1.RECORDSOURCE = THISFORM.GRID1.RECORDSOURCE
ID članka: 140653 – Zadnji pregled: 20. jun. 2008 – Revizija: 1