DOCUMENT:Q253882 21-JUL-2000 [foxpro] TITLE :HOWTO: Use a DataGrid ActiveX Control in Visual FoxPro PRODUCT :Microsoft FoxPro PROD/VER:WINDOWS:6.0 OPER/SYS: KEYWORDS:kbActiveX kbADO kbContainer kbCtrl kbvfp600 kbVS600sp3 kbGrpDSFox kbDSupport ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, version 6.0 ------------------------------------------------------------------------------- SUMMARY ======= The Microsoft DataGrid control (Msdatgrd.ocx) cannot directly use Microsoft Visual FoxPro tables as a data source. The DataGrid control can, however, be bound to an ActiveX Data Objects (ADO) recordset. This article illustrates how to bind a DataGrid ActiveX control to an ADO recordset from within a Visual FoxPro application. You must have Visual Studio Service Pack 3 installed for this code to function. MORE INFORMATION ================ NOTE: The Microsoft DataGrid control has not been tested with and is not supported by Microsoft Visual FoxPro. In order to bind a DataGrid ActiveX control to an ADO recordset, a recordset that can be bookmarked or a client side ADO recordset must first be created. After this ADO recordset has been created, the DataGrid.DataSource property is used to bind the control with the ADO recordset, as follows: THISFORM.DataGrid1.DATASOURCE=myADORecordSet 1. Create a program file named "Datagrid.prg" (without the quotation marks) using the following code: PUBLIC OX OX=CREATEOBJECT('MYFORM') OX.SHOW READ EVENTS DEFINE CLASS myform AS FORM CAPTION = "DataGrid Form" HEIGHT = 250 LEFT = 0 TOP = 0 WIDTH = 375 NAME = "myform" ADD OBJECT DataGrid1 AS OLECONTROL WITH ; OLECLASS="MSDataGridLib.DataGrid.1",; TOP = 25, ; LEFT = 25, ; HEIGHT = 190, ; WIDTH = 325, ; NAME = "DataGrid1" ADD OBJECT commandbutton1 AS COMMANDBUTTON WITH ; TOP=225, ; LEFT=275, ; HEIGHT=25, ; CAPTION="\