behaviour of listbox in wbrowse

behaviour of listbox in wbrowse

Postby Detlef » Fri Mar 04, 2022 5:27 pm

Dear all,
I have an issue with xBrowse when using listbox editing.
When selecting a listbox entry to assign to my person it works.
Then I select the same row and open the listbox by cklick at the triangle button.
If I decide not to select an item but click outside of the listbox the original column value is overwritten with always the first item of the listbox.

Is There a way to keep the old value when cancelling the listbox editing?

Here some code for demonstration:
Code: Select all  Expand view
#include "FiveWin.ch"
#include "xbrowse.ch"

   REQUEST DBFCDX
   REQUEST DBFFPT

   FIELD name

//-------------
FUNCTION Main()
//-------------
LOCAL oWnd, oBrw
LOCAL aSel := { "Golf", "Football", "Knitting", "Singing", "Drinking" }


   OpenDbf( aSel )

   DEFINE WINDOW oWnd

      @ 10, 10 XBROWSE oBrw OF oWnd;
         ALIAS "ppl";
         HEADERS "Name"  , "Interest", "Age"    ;
         COLUMNS "name"  , "interest", "age"    ;
         COLSIZES 100    ,  200      ,  40      ;
         JUSTIFY  "LEFT" , "LEFT"    , "CENTER" ;
         CELL LINES FASTEDIT

      WITH OBJECT oBrw
         :nRowDividerStyle := 1
         :nColDividerStyle := 3
         :nMarqueeStyle    := MARQSTYLE_HIGHLCELL
         :nDataLines       := 1
         :nRowHeight       := :oFont:nHeight * 2.5
         :nStretchCol      := STRETCHCOL_LAST
         :nMoveType        := MOVE_FAST_RIGHT

         :aCols[ 1 ]:nEditType      := EDIT_GET
         :aCols[ 2 ]:nEditType      := EDIT_GET_LISTBOX
         :aCols[ 2 ]:aEditListTxt   := aSel
         :aCols[ 3 ]:nEditType      := EDIT_GET
      END

      oBrw:CreateFromCode()
      oWnd:oClient   := oBrw

   ACTIVATE WINDOW oWnd ON INIT oWnd:center()

RETURN( NIL )

//----------------------------
PROCEDURE OpenDbf( aInterest )
//----------------------------
LOCAL lInit   := .f.
LOCAL aPeople := { "Jack", "Melissa", "Ernest", "George", "Melvin", "Brovira", "June", "Mike", "Penelope", "Stan", "Laurel" }
LOCAL cPerson


   if !file( "people.dbf" )
      lInit := .t.

      DbCreate( "people", {;
             { "ID",      "C",   8, 0 },;
             { "NAME",    "C", 128, 0 },;
             { "INTEREST","C", 128, 0 },;
             { "AGE",     "N",   3, 0 } ;
         }, "DBFcdx" )
   endif

   use people via "dbfcdx" exclusive alias ppl new

   if file( "people.cdx" )
      ferase( "people.cdx" )
   endif

   index on name tag name

   ppl->( ordSetFocus( "name" ) )
   ppl->( DbGoTop() )

   if lInit
      For each cPerson in aPeople
         ppl->( dbAppend() )

         ppl->name := cPerson
         ppl->interest := aInterest[ HB_RandomInt( 1, len( aInterest ) ) ]
         ppl->age  := HB_RandomInt( 18, 100 )
      Next
   endif

   ppl->( dbGoTop() )
RETURN
 
User avatar
Detlef
 
Posts: 205
Joined: Mon Feb 07, 2022 9:54 pm

Re: behaviour of listbox in wbrowse

Postby Antonio Linares » Sat Mar 05, 2022 8:29 am

Dear Detlef,

Here it seems to be working fine:
Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41329
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: behaviour of listbox in wbrowse

Postby karinha » Sat Mar 05, 2022 12:20 pm

Code: Select all  Expand view

// \SAMPLES\DETLEF.PRG

#include "FiveWin.ch"
#include "xbrowse.ch"

REQUEST DBFCDX, DBFFPT

STATIC oWnd

FUNCTION Main()

   FIELD NAME, INTERES, AGE

   LOCAL oBrw, cTitle
   LOCAL aSel := { "Golf", "Football", "Knitting", "Singing", "Drinking" }

   MsgRun( "WAIT... OPEN A DBF.",                 ;
           "Please, Wait...    ",                 ;
           { || WinExec( OpenDbf( aSel ) ), 3 } )

   cTitle := "Behaviour of listbox in xbrowse perfect."

   DEFINE WINDOW oWnd TITLE cTitle

   @ 10, 10 XBROWSE oBrw OF oWnd        ;
      ALIAS "ppl"                       ;
      HEADERS "Name", "Interest", "Age" ;
      COLUMNS "name", "interest", "age" ;
      COLSIZES 100,  200,  40           ;
      JUSTIFY  "LEFT", "LEFT", "CENTER" ;
      CELL LINES FASTEDIT

   WITH OBJECT oBrw

      :nRowDividerStyle := 1
      :nColDividerStyle := 3
      :nMarqueeStyle    := MARQSTYLE_HIGHLCELL
      :nDataLines       := 1
      :nRowHeight       := :oFont:nHeight * 2.5
      :nStretchCol      := STRETCHCOL_LAST
      :nMoveType        := MOVE_FAST_RIGHT

      :aCols[ 1 ]:nEditType      := EDIT_GET
      :aCols[ 2 ]:nEditType      := EDIT_GET_LISTBOX
      :aCols[ 2 ]:aEditListTxt   := aSel
      :aCols[ 3 ]:nEditType      := EDIT_GET

   END

   oBrw:CreateFromCode()
   oWnd:oClient := oBrw

   ACTIVATE WINDOW oWnd ON INIT( oWnd:center() )

RETURN NIL

FUNCTION OpenDbf( aInterest )

   FIELD ID, NAME, INTEREST, AGE

   LOCAL lInit   := .F.
   LOCAL aPeople := { "Jack", "Melissa", "Ernest", "George", "Melvin", "Brovira", "June", "Mike", "Penelope", "Stan", "Laurel" }
   LOCAL cPerson

   IF .NOT. FILE( "people.dbf" )

      lInit := .T.

      dbCreate( "people", { ;
         { "ID",      "C",   8, 0 }, ;
         { "NAME",    "C", 128, 0 }, ;
         { "INTEREST", "C", 128, 0 }, ;
         { "AGE",     "N",   3, 0 } ;
         }, "DBFcdx" )
   ENDIF

   USE people VIA "dbfcdx" EXCLUSIVE ALIAS ppl new

   IF FILE( "people.cdx" )

      FErase( "people.cdx" )

   ENDIF

   INDEX ON name TAG name

   ppl->( ordSetFocus( "name" ) )
   ppl->( dbGoTop() )

   IF lInit

      FOR EACH cPerson in aPeople

         ppl->( dbAppend() )

         RLOCK()

         ppl->name     := cPerson
         ppl->interest := aInterest[ hb_RandomInt( 1, Len( aInterest ) ) ]
         ppl->age      := hb_RandomInt( 18, 100 )

      NEXT

      COMMIT
      UNLOCK

   ENDIF

   ppl->( dbGoTop() )

RETURN NIL

// FIN / END
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7261
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: behaviour of listbox in wbrowse

Postby Detlef » Sat Mar 05, 2022 1:32 pm

Antonio Linares wrote:Dear Detlef,
Here it seems to be working fine: ...


Dear Antonio,
thanks for your reply.
I think my issue is due to my FWH version which is rather outdated, "FiveWin for xHarbour 10.2 - Feb. 2010".
Maybe I could solve my problem by coding a bLostFocus block?

Please, an other question. Do you know why the CENTER clause for column 'age' is ignored?
Regards, Detlef
User avatar
Detlef
 
Posts: 205
Joined: Mon Feb 07, 2022 9:54 pm

Re: behaviour of listbox in wbrowse

Postby Detlef » Sat Mar 05, 2022 1:37 pm

karinha wrote:[code=fw]
// \SAMPLES\DETLEF.PRG .....

Hi karinha,
Your suggest doesn't solve my problem.
But please, explain to me: why do you put the variable oWnd outside the Main function as STATIC ?

Regards, Detlef
User avatar
Detlef
 
Posts: 205
Joined: Mon Feb 07, 2022 9:54 pm

Re: behaviour of listbox in wbrowse

Postby karinha » Sun Mar 06, 2022 12:21 pm

Code: Select all  Expand view

// \SAMPLES\DETLEF3.PRG

#include "FiveWin.ch"
#include "xbrowse.ch"

ANNOUNCE RDDSYS
REQUEST DBFCDX, DBFFPT

// STATIC oWnd         // TEST
STATIC lInit   := .F.  // TEST

FUNCTION Main()

   FIELD NAME, INTERES, AGE

   LOCAL oBrw, cTitle, oWnd
   LOCAL aSel := { "Golf", "Football", "Knitting", "Singing", "Drinking" }

   RDDSETDEFAULT("DBFCDX")

   MsgRun( "WAIT... OPEN A DBF.",                 ;
           "Please, Wait...    ",                 ;
           { || WinExec( OpenDbf( aSel ) ), 3 } )

   cTitle := "Behaviour of listbox in xbrowse perfect in Version 3."

   DEFINE WINDOW oWnd TITLE cTitle

   @ 10, 10 XBROWSE oBrw OF oWnd        ;
      ALIAS "ppl"                       ;
      HEADERS "Name", "Interest", "Age" ;
      COLUMNS "name", "interest", "age" ;
      COLSIZES 100,  200,  40           ;
      JUSTIFY  "LEFT", "LEFT", "CENTER" ;
      CELL LINES FASTEDIT

   WITH OBJECT oBrw

      :nRowDividerStyle := 1
      :nColDividerStyle := 3
      :nMarqueeStyle    := MARQSTYLE_HIGHLCELL
      :nDataLines       := 1
      :nRowHeight       := :oFont:nHeight * 2.5
      :nStretchCol      := STRETCHCOL_LAST
      :nMoveType        := MOVE_FAST_RIGHT

      :aCols[ 1 ]:nEditType      := EDIT_GET
      :aCols[ 2 ]:nEditType      := EDIT_GET_LISTBOX
      :aCols[ 2 ]:aEditListTxt   := aSel
      :aCols[ 3 ]:nEditType      := EDIT_GET

   END

   oBrw:CreateFromCode()
   oWnd:oClient := oBrw

   ACTIVATE WINDOW oWnd ON INIT( oWnd:center() )

   lInit   := .F.

RETURN NIL

FUNCTION OpenDbf( aInterest )

   FIELD ID, NAME, INTEREST, AGE

   LOCAL aPeople := { "Jack", "Melissa", "Ernest", "George", "Melvin", "Brovira", "June", "Mike", "Penelope", "Stan", "Laurel" }
   LOCAL cPerson, PPL

   IF .NOT. FILE( "PEOPLE.dbf" )

      lInit := .T.

      dbCreate( "PEOPLE", { ;
         { "ID",      "C",   8, 0 }, ;
         { "NAME",    "C", 128, 0 }, ;
         { "INTEREST", "C", 128, 0 }, ;
         { "AGE",     "N",   3, 0 } ;
         }, "DBFcdx" )

   ENDIF

   USE PEOPLE EXCLUSIVE NEW  // FOR INDEX ONLY.

   IF FILE( "PEOPLE.cdx" )

      FErase( "PEOPLE.cdx" )

   ENDIF

   INDEX ON NAME TAG NAME TO PEOPLE

   CLOSE DATABASE

   USE PEOPLE SHARED NEW ALIAS PPL

   PPL := ALIAS()

   PPL->( ordSetFocus( "NAME" ) )
   PPL->( dbGoTop() )

   IF lInit

      FOR EACH cPerson in aPeople

         PPL->( dbAppend() )

         RLOCK()

         PPL->NAME     := cPerson
         PPL->INTEREST := aInterest[ hb_RandomInt( 1, Len( aInterest ) ) ]
         PPL->AGE      := hb_RandomInt( 18, 100 )

      NEXT

   ENDIF

   PPL->( dbGoTop() )

RETURN NIL

// FIN / END
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7261
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: behaviour of listbox in wbrowse

Postby Detlef » Sun Mar 06, 2022 2:14 pm

Hi karinha,
many thanks for your efforts.But it doesn't work for me.
Please, read my reply to Antonio.
There I wrote that my problem must be caused due to my outdated FiveWin version.

Regards
Detlef
User avatar
Detlef
 
Posts: 205
Joined: Mon Feb 07, 2022 9:54 pm

Re: behaviour of listbox in wbrowse

Postby Detlef » Tue Mar 08, 2022 9:34 am

Dear all,
I want ask again why for column 3 of my sample code the CENTER clause is ignored.
Even the example of Antonio does not center the column 'age'.
And Antonio surely has not an outdated FWH version as me. :)
User avatar
Detlef
 
Posts: 205
Joined: Mon Feb 07, 2022 9:54 pm

Re: behaviour of listbox in wbrowse

Postby Detlef » Tue Mar 08, 2022 6:58 pm

Sorry, FiveWinners,
it was my fault.
Instead of "CENTER" I had to write AL_CENTER.

Shame on me.
User avatar
Detlef
 
Posts: 205
Joined: Mon Feb 07, 2022 9:54 pm

Re: behaviour of listbox in wbrowse

Postby karinha » Tue Mar 08, 2022 7:15 pm

Esto?

Code: Select all  Expand view

   @ 10, 10 XBROWSE oBrw OF oWnd               ;
      ALIAS "ppl"                              ;
      HEADERS "Name", "Interest", "Age", "End" ;
      COLUMNS "name", "interest", "age", " "   ;
      COLSIZES 100,  200,  120, 10             ;
      JUSTIFY  .F., .F., AL_CENTER, .F.        ;
      CELL LINES FASTEDIT
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7261
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: behaviour of listbox in wbrowse

Postby Detlef » Thu Mar 10, 2022 3:31 pm

Yes, you are right. :)
User avatar
Detlef
 
Posts: 205
Joined: Mon Feb 07, 2022 9:54 pm


Return to FiveWin for Harbour/xHarbour

Who is online

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