JavaScript Editor js editor     Web development 



Main Page

Specifies the source of data to which the Grid control is bound. Available at design time; read/write at run time.

Grid.RecordSource[ = cName]

Return Value

cName


cName is typically the alias name of a cursor or the name of a table. The RecordSource property specifies the main cursor that the grid is bound to.

Remarks

Applies To: Grid

If you specify a record source for a grid, you can specify the contents of individual columns in the grid by setting the columns' ControlSource property. If you do not set the ControlSource property for a grid column, the column displays the next available and field in the grid's record source that is not yet displayed. For more information, see ControlSource Property.

When you are working with grids, you might sometimes need to change or query the RecordSource property again at run time. Because the new source might have a different structure than the previous source, Visual FoxPro resets column settings, such as the width and font, to their default values. When you want to preserve the previous settings, for example, in scenarios when the new record source has the same structure as the previous one, you can use the SPACE(В ) function set the RecordSource property temporarily to SPACE(0).

Note:
Using SPACE(0) might not preserve all the grid settings that you want. You might need to reset some settings in code after setting the RecordSource property.

The following code example uses the Customers table in the Northwind sample database in the Visual FoxPro directory ..\Samples\Northwind\ and illustrates how to preserve the previous settings:

В Copy Code
PUBLIC oForm
oForm=NEWOBJECT("MyForm")
oForm.Show()

DEFINE CLASS MyForm AS Form
    ADD OBJECT oGrid1 AS Grid WITH RecordSource="MyCust",ColumnCount=3
    ADD OBJECT oButton1 AS CommandButton WITH TOP = 200

    PROCEDURE Load
      SELECT * FROM HOME()+"Samples\Northwind\Customers" ;
        WHERE Country="France" INTO CURSOR MyCust

    PROCEDURE Init
        THISFORM.oGrid1.Column1.Width = 50
        THISFORM.oGrid1.Column1.FontSize=14
        THISFORM.oGrid1.Column2.Width = 50
        THISFORM.oGrid1.Column3.Width = 50

    PROCEDURE oButton1.Click
        THISFORM.oGrid1.RecordSource = SPACE(0)
        SELECT * FROM HOME()+"Samples\Northwind\Customers" ;
           WHERE Country="France" INTO CURSOR MyCust
           THISFORM.oGrid1.RecordSource = "MyCust"
   
ENDDEFINE

See Also



JavaScript Editor js editor     Web development