FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Help with XBrowse
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Help with XBrowse
Posted: Fri Feb 05, 2010 05:52 PM
In the following sample, if I click on a row (ie. the last row) the clicked row moves up. Why?

Code (fw): Select all Collapse
#include "Fivewin.ch"
#include "XBrowse.ch"


FUNCTION MAIN()

    LOCAL oDlg, oBrw

    LOCAL aArray := { { "Row1-Col1", "Row1-Col2", "Row1-Col3" },;
                      { "Row2-Col1", "Row2-Col2", "Row2-Col3" },;
                      { "Row3-Col1", "Row3-Col2", "Row3-Col3" },;
                      { "Row4-Col1", "Row4-Col2", "Row4-Col3" } }

    LOCAL nCur := 1

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    @ 0, 0 XBROWSE oBrw FIELDS aArray[ nCur, 1 ],;
                               aArray[ nCur, 2 ],;
                               aArray[ nCur, 3 ];
           HEADERS "COL1", "COL2", "COL3";
           ARRAY aArray

    oBrw:CreateFromCode()

    oBrw:bGoTop    = { || nCur := 1 }
    oBrw:bGoBottom = { || nCur := Len( aArray ) }
//    oBrw:bBof      = { || nCur = 1 }
//    oBrw:bEof      = { || nCur = Len( aArray ) }
//    oBrw:bKeyCount = { || Len( aArray ) }
//    oBrw:bPastEof  = { || nCur > Len( aArray ) }
    oBrw:bBookMark = { | nBkm | If( nBkm == nil, nCur, nCur := nBkm ) }
    oBrw:bSkip     = { | nSkip | Skipper( aArray, @nCur, nSkip ) }

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             CENTER

    RETURN NIL


STATIC FUNCTION SKIPPER( aArray, nCur, nSkip )

    LOCAL nOld := nCur

    DEFAULT nSkip := 1

    nCur += nSkip

    IF nCur > LEN( aArray ); nCur = LEN( aArray ); ENDIF
    IF nCur < 1; nCur = 1; ENDIF

    RETURN nCur - nOld


EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Help with XBrowse
Posted: Fri Feb 05, 2010 05:54 PM

And, by the way, how to activate autosort in all the column while browsing an array? Any better array browsing sample than mine?

EMG

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Help with XBrowse
Posted: Fri Feb 05, 2010 06:16 PM

I beleive that xBrowse does all the settings automatically

@0.0 XBROWSE oBrw ARRAY aArray

oBrw:CreateFromCode()

Rest it will set automatically

Regards
Anser

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Help with XBrowse
Posted: Fri Feb 05, 2010 06:21 PM
This is the code
Code (fw): Select all Collapse
#include "Fivewin.ch"
#include "XBrowse.ch"


FUNCTION MAIN()

    LOCAL oDlg, oBrw

    LOCAL aArray := { { "Row1-Col1", "Row1-Col2", "Row1-Col3" },;
                      { "Row2-Col1", "Row2-Col2", "Row2-Col3" },;
                      { "Row3-Col1", "Row3-Col2", "Row3-Col3" },;
                      { "Row4-Col1", "Row4-Col2", "Row4-Col3" } }




    DEFINE DIALOG oDlg;
           SIZE 800, 600


    @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
         COLUMNS 1, 2, 3 ;
         HEADERS 'COL1', 'COL2', 'COL3' ;
         ARRAY aArray ;
         AUTOSORT ; // for auto-sorting 
         CELL LINES NOBORDER // optinal

    oBrw:CreateFromCode()

    ACTIVATE DIALOG oDlg CENTERED

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM

Continue the discussion