Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using a treeview to show results of a query
Message
De
27/06/2005 10:18:33
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01026663
Message ID:
01026709
Vues:
14
>I have a cursor which has been populated with an SQL statement. The contents of the cursor shows the type of record and who created it. I would like to display this in a treeview on a form. For example:
>
>
>SAMPLE    JKT001   Lesley
>SAMPLE    JKT002   Mark
>TECHNICAL JKT564   Brian
>
>
>When I display this in the form I would like to see:
>
>
>SAMPLE (2)
>          JKT001    Lesley
>          JKT002    Mark
>TECHNICAL (1)
>          JKT564    Brian
>
>Can anybody help me in hwo I would do this.
Create Cursor queryresults (f1 c(10), f2 c(10), f3 c(10))
Insert Into queryresults Values ('SAMPLE','JKT001','Lesley')
Insert Into queryresults Values ('SAMPLE','JKT002','Mark')
Insert Into queryresults Values ('TECHNICAL','JKT564','Brian')

* Define some constants.
#Define tvwFirst	0
#Define tvwLast	1
#Define tvwNext	2
#Define tvwPrevious	3
#Define tvwChild	4

Public oForm
oForm = Createobject('myForm')
oForm.Show

Define Class myForm As Form
  Height = 300
  Width = 500

  Add Object myTree As OleControl With ;
    Height = 300, ;
    Width = 500, ;
    OleClass = 'MSComCtlLib.TreeCtrl'

  Procedure filltree
    Select f1,Cnt(*) ;
      From queryresults ;
      group By 1 ;
      Into Array parentnodes
    With This.myTree.nodes
      For ix=1 To _Tally
        .Add(,tvwFirst,Trim(parentnodes[m.ix,1]),;
          Textmerge('<<Trim(parentnodes[m.ix,1])>> - (<<parentnodes[m.ix,2]>>)'))
      Endfor
      Select queryresults
      Scan
        .Add(Trim(f1), tvwChild, ;
          Padl(Recno(),5,'_'), Trim(f2-(' '+f3)))
      Endscan
    Endwith
  Endproc

  Procedure Init
    This.myTree.linestyle =1
    This.filltree()
  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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform