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