Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use msflexgrid in visual foxpro
Message
From
24/08/2001 03:10:18
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
24/08/2001 01:25:58
Devrishi Bhogra
Escorts Claas Limited
Faridabad, India
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00548484
Message ID:
00548505
Views:
23
>Hi there!!
>
>What to do, if want to use msflexgrid in my visual foxpro application.
>how to specify data source.
>
>please help
>
>regards
>
>Sunny

Forget MSFlexGrid when there is MSHflexgrid. It can do everything MSFlexgrid could do plus more.
* HierarchicalFlexGrid sample
* Author : Cetin Basoz
* A simple sample demonstrating why HFlexGrid might be much more powerfull and easy 
* than MSFlexgrid and treeview when you have related data
* Keep in mind this is only entry level what you can do with it.
* Also it shows ADO shaping power ;) Thanks to fox team

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

Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform