change from Dbf to tree and vice versa

change from Dbf to tree and vice versa

Postby Silvio.Falconi » Wed Mar 08, 2023 10:05 pm

Could you convert this small example using Tdatabase() and using a combobox instead of btnbmp to select tree->dbf


Code: Select all  Expand view  RUN


function TestTree()

   local oDlg, oBrw

   USE CUSTOMER NEW
   SET ORDER TO TAG STATE
   GO TOP

   DEFINE DIALOG oDlg SIZE 800,400 PIXEL TRUEPIXEL
   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE Alias()  ;
      COLUMNS "STATE", "CITY", "STREET", "ZIP", "AGE" ;
      CELL LINES NOBORDER

   oBrw:lDisplayZeros   := .f.
   oBrw:CreateFromCode()

   @ 10, 20 BTNBMP PROMPT "TREE" SIZE 150,30 PIXEL OF oDlg FLAT ;
      WHEN oBrw:nDataType == DATATYPE_RDD ;
      ACTION oBrw:SetTree( BuildTree(), {  "open", "close", "go" } )

   @ 10,200 BTNBMP PROMPT "DBF" SIZE 150,30 PIXEL OF oDlg FLAT ;
      WHEN oBrw:nDataType != DATATYPE_RDD ;
      ACTION ( CUSTOMER->( oBrw:SetRDD( nil, nil, { "STATE", "CITY", "STREET", "ZIP", "AGE" } ) ), ;
               oBrw:GoTop() )

   ACTIVATE DIALOG oDlg CENTERED
   CLOSE CUSTOMER

return nil



static function BuildTree()

   local oTree, cState

   TREE oTree
      while ! Eof()
         if Empty( cState )
            _TreeItem( Customer->State ):Cargo := { Space( 20 ), Space( 20 ) }
            TREE
            cState = Customer->State
         else
            if cState != Customer->State
               ENDTREE
               cState = Customer->State
               _TreeItem( Customer->State ):Cargo := { Space( 20 ), Space( 20 ) }
               TREE
            endif  
         endif  
         if Customer->State == cState
            _TreeItem( Customer->City ):Cargo := { Customer->Last, Customer->First }
         endif  
         SKIP
      enddo
      ENDTREE
   ENDTREE

   GO TOP

return oTree






 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7066
Joined: Thu Oct 18, 2012 7:17 pm

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 58 guests

cron