Página 1 de 1

TBrowse problem

Publicado: Lun Ago 07, 2006 4:37 pm
por Giuseppe Bogetti
Hi,
I'm trying to use the basic TBrowse object but I cannot make it work.
Here is the code I use.
//---------------------------------------------------------- --------------------
METHOD FormInitialize( oSender ) CLASS TForm1
// Apertura tabella
USE "W:Nova6Artico.dbf" ALIAS artico
artico->( OrdSetFocus( 1 ) )
// Creazione browser
WITH OBJECT ::oBrw := TBrowse():New( ::oDbPanel )
:nAlign := alCLIENT
WITH OBJECT TBrwColumn():New( hb_QWith() )
:cHeader := "Codice"
:OnGetData := {|o| artico->( FieldGet( 3 ) ) }
:Create()
END WITH
WITH OBJECT TBrwColumn():New( hb_QWith() )
:cHeader := "Descrizione"
:OnGetData := {|o| RTrim( artico->( FieldGet( 4 ) ) ) + " " +
;
RTrim( artico->( FieldGet( 5 ) ) ) }
:Create()
END WITH
// Creazione browser
:Create()
// Inizializzazione eventi
:OnGoTop := {|o| artico->( dbGoTop() ) }
:OnGoBottom := {|o| artico->( dbGoBottom() ) }
:OnSkip := {|o,n| ::Skipper( o, n ) }
:OnBof := {|o| artico->( Bof() ) }
:OnEof := {|o| artico->( Eof() ) }
:OnBookMark := {|o, n| iif( n == nil, artico->( RecNo() ), artico->(
dbGoTo( n ) ) ) }
:OnKeyNo := {|o, n| iif( n == nil, artico->( RecNo() ), artico->(
dbGoTo( n ) ) ) }
:OnKeyCount := {|o| artico->( LastRec() ) }
// Visualizzazione tabella
AltD()
:Refresh( .t. )
END WITH
RETURN Nil
//---------------------------------------------------------- --------------------
METHOD Skipper( oSender, n2Skip ) CLASS TForm1
LOCAL nSkipped AS NUMERIC := 0
IF ( n2Skip == Nil )
n2Skip := 1
ENDIF
WHILE ( nSkipped # n2skip )
IF ( n2skip > 0 )
// FORWARD
artico->( DbSkip( 1 ) )
IF ( artico->( Eof() ) )
artico->( DbSkip( -1 ) )
EXIT
ELSE
nSkipped++
ENDIF
ELSE
// BACKWARD
artico->( DbSkip( -1 ) )
IF ( artico->( Bof() ) )
EXIT
ELSE
nSkipped--
ENDIF
ENDIF
ENDDO
RETURN nSkipped
When I execute the form in debug mode, I've noticed that the OnSkip event
is never fired and the browse displays the content of the first record of
the table in every row.
When all the rows are filled it gives the following error:
Chiamata a sottosistema: BASE
Codice di sistema: 1081
Stato di default: .F.
Descrizione: Argument error
Operazione: +
Argomenti: [ 1] = Tipo: N Val: 7639 [ 2] = Tipo: U Val: NIL
File coinvolti:
Codice di errore Dos: 0
Chiamato da:
TBROWSE:WMPAINT (157)
UPDATEWINDOW (0)
(b)XCONTROL:XCONTROL (90)
TFORM1:UPDATE (0)
TFORM1:WMNCACTIVATE (729)
SHOWWINDOW (0)
TSCROLLINGWINCONTROL:SHOW (582)
TFORM1:SHOW (430)
MAIN (19)
Can someone please explain what am I doing wrong ?
--
Best regards,
Giuseppe Bogetti
B.G. Soft
Cuneo - Italy