oForm = createobject('myForm') oForm.Show Read events Define CLASS myForm AS form Top = 0 Left = 0 Height = 450 Width = 750 DoCreate = .T. Caption = "HFlex Sample" Name = "Form1" Add OBJECT hflex AS olecontrol WITH ; Top = 0, ; Left = 0, ; Height = 420, ; Width = 750, ; Name = "Hflex", ; OleClass = "MSHierarchicalFlexGridLib.MSHFlexGrid" Procedure Init #Define TESTDATALOC C:\ddrive\TEMP\testdata.DBC Local oRecordset,oConnection, strCn, strShp lcSel1 = [ select customer.cust_id, ]+; [ customer.Company,]+; [ orders.order_id,]+; [ orders.Order_date ]+; [ from customer ]+; [ inner join orders on customer.cust_id = orders.cust_id ]+; [ where customer.cust_id like 'A%' ] lcSel2 = [ select od.order_id, od.line_no, ]+; [ products.prod_name, ]+; [ products.no_in_unit as 'Packaging', ]+; [ od.unit_price, ]+; [ od.Quantity, ]+; [ od.unit_price * od.quantity as ExtendedPrice ]+; [ from orditems as od ]+; [ inner join products on od.product_id = products.product_id ] strShp = [ SHAPE ]+; [(SHAPE {]+lcSel1+[ } as rs1 ]+; [ APPEND ({]+lcSel2+[ } AS rsDetails RELATE order_id TO order_id), ]+; [ SUM(rsDetails.ExtendedPrice) AS OrderTotal, ]+; [ ANY(rsDetails.order_id)) AS rsOrders ]+; [COMPUTE rsOrders, ]+; [SUM(rsOrders.OrderTotal) AS CustTotal, ]+; [ANY(rsOrders.Company) AS Cmpny ]+; [ BY cust_id ] strCn = [Provider=MSDataShape.1;Persist Security Info=False;]+; [Data Source="Data Provider = MSDASQL;]+; [DSN=Visual FoxPro Database;UID=;SourceDB=TESTDATALOC;]+; [SourceType=DBC;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;]+; [Deleted=Yes;";Data Provider=MSDASQL ] oRecordset = CreateObject("adodb.recordset") oConnection = CreateObject("adodb.connection") With oConnection .Provider = "MSDataShape" .ConnectionString = strCn .Open Endwith With oRecordset .ActiveConnection = oConnection .Source = strShp .Open Endwith With this.hflex .FixedCols = 0 .AllowUserResizing = 1 && Allow col sizing .Datasource = oRecordset .Mergecells = 3 .GridColorBand(0) = rgb(255,0,0) && Play with gridline coloring .GridColorBand(1) = rgb(0,0,255) .GridColorBand(2) = rgb(0,255,0) .ColPosition(2,0) = 0 && Change col ordering .ColPosition(2,0) = 1 .ColPosition(2,1) = 0 .ColWidth(1,1) = 0 && Make some cols invisible .ColWidth(2,1) = 0 .ColWidth(5,1) = 0 .ColWidth(0,2) = 0 Endwith Endproc Procedure queryunload Clear events Endproc EnddefineCetin