Guidance
指路人
g.yi.org
software / rapidq / Examples / Database / dbase / browser.rqb

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'-- Control Alignments
     CONST alNone = 0
     CONST alTop = 1
     CONST alBottom = 2
     CONST alLeft = 3
     CONST alRight = 4
     CONST alClient = 5           '-- Expand to fit client

'-- Cursor
     CONST crHSplit = -14
     CONST crVSplit = -15


     $INCLUDE "dbtools.inc"
     $INCLUDE "dbt.inc"
     $INCLUDE "dbase.inc"

     DECLARE SUB readtable

     IF COMMANDCOUNT = 1  THEN
      dbopen(COMMAND$(1), fmOpenRead)
     ELSE
      SHOWMESSAGE "Syntax: Browser tablename"
      END
     END IF

     recs% = 200

'Based on a listing found at the examples folder.
     CREATE frame AS QFORM
      Height = 350
      center
      CAPTION = "Table browser"
      Visible = 1                  '-- Required
      Visible = 0                  '-- trick

      CREATE Panel AS QPANEL
       Align = alTop              '-- Fill top portion of form
       Height = 100
       CAPTION = "Click to load"
       OnClick = readTable
      END CREATE

      CREATE Splitter AS QSPLITTER
       Align = alTop      '-- Note position
       Cursor = crVSplit  '-- Fill middle
       Height = 10
      END CREATE

      CREATE browse AS QSTRINGGRID
       Align = alClient         '-- Fill rest of form
       colcount = fCount()
       rowcount = recs%+1     'lastRec()+1  including headers of columns
'  fixedcols = 0
      END CREATE

      onClose = dbclose
     END CREATE

     frame.SHOWMODAL
'dbclose

'---------------------------------
'Load grid with data
'Very Slow !!!

     SUB readTable
      lonheader%=0
      lonStr% = 0
      DIM __r AS VARIANT

'Real Data
'Fill columns

      SHOWMESSAGE "Browsing table..."

      FOR i% = 1 TO browse.colcount
       __name$ = fieldname(i%)

       browse.cell(i%-1,0 ) = __name$
       lonHeader% = LEN(__name$)

'  ShowMessage __name$
       lonStr% = LengthOf( __name$ )      'Data
'  ShowMessage "About to Processing column.."

  'Request space
       browse.colWidths(i%-1) = frame.TextWidth( _
        STRING$(IIF(lonStr%>=lonheader%, lonStr%, lonheader%), "D"))

       FOR j&=1 TO recs%      'lastRec()  or browse.rowcount
        dbgoto(j&)

        panel.CAPTION = "Rec# :  " + STR$(recno()) + "  Column  ->" +STR$(i%)
        panel.repaint

        __r = fieldget(i%)        'It is a variant

        SELECT CASE TypeOf(__name$)
        CASE "C"
         browse.cell(i%-1, j&) = __r

        CASE "D"
         browse.cell(i%-1, j&) = __r

        CASE "N"
         DEC? = decimalsOf(__name$)
         browse.cell(i%-1, j&) = Format$("%"+STR$(lonStr%)+"."+STR$(DEC?)+"f", __r)

        CASE "M"
         browse.cell(i%-1, j&) = "Memo"
      'edt(i%).Text = Str$(__r)
        CASE "L"
         browse.cell(i%-1, j&) = IIF(__r = FALSE, "F", "T")
        END SELECT
       NEXT
      NEXT

      panel.CAPTION = "Loaded " & STR$(recs%) & " records.."
      panel.repaint
     END SUB

掌柜推荐
 
 
¥289.00 ·
 
 
¥1,080.00 ·
 
 
¥1,380.00 ·
 
 
¥638.00 ·
 
 
¥1,290.00 ·
 
 
¥1,420.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-10-22 14:12:20