the code don't work as expected for EDIT_LISTBOX
What are bad on the code ?
please help me
- Code: Select all Expand view
- #include 'fivewin.ch'
#include 'xbrowse.ch'
function main()
local aKeys := {'pichincha','internacio'}
local hBancos := { => }
local hRow
local aCols := {}
local oWnd
local oBrw
local i
local oCol1
local cDbf := '.\test1.dbf'
local aDbf := { { 'codigo' , 'C', 10, 0 } ,;
{ 'pichincha' , 'C', 15, 0 } ,;
{ 'internacio' , 'C', 15, 0 } }
hBancos ['pichincha'] = {}
hRow = { 'numcuenta' => '1234567' }
aadd( hBancos ['pichincha'], hRow )
hBancos ['internacio'] = {}
hRow = { 'numcuenta' => '890123' }
aadd( hBancos ['internacio'], hRow )
dbcreate( cDbf, aDbf )
use ( cDbf ) new alias camello exclusive
camello->( dbappend() )
camello->codigo = '1'
camello->( dbappend() )
camello->codigo = '2'
camello->( dbgotop() )
DEFINE WINDOW oWnd
@ 0,0 XBROWSE oBrw OF oWnd alias 'camello' fastedit
oCol1 := oBrw:AddCol()
oCol1:bEditValue := { || ( oBrw:cAlias )->codigo }
oCol1:cHeader := "codigo"
oCol1:cEditPicture:= "@!"
oCol1:nEditType := 0
oCol1:nWidth := 90
aCols = {}
for i = 1 to len( aKeys )
aadd( aCols, oBrw:AddCol() )
campotexto( oBrw, i+1, @aCols, i, hBancos, aKeys )
next
oBrw:CreateFromCode()
ACTIVATE WINDOW oWnd
return nil
function campotexto( oBrw, i, aCols, n, hBancos, aKeys )
local xValue
local uRet
local c
local aRow
local aEditListTxt
local aEditListBound
local j
local hRow
aRow = hBancos[ aKeys[n] ]
aEditListTxt = {}
aEditListBound = {}
for j = 1 to len( aRow )
hRow = aRow[j]
aadd( aEditListTxt , hRow['numcuenta'] )
aadd( aEditListBound, hRow['numcuenta'] )
next
c = alltrim( lower( ( oBrw:cAlias )->( fieldname( i ) ) ) )
aCols[ n ]:bEditValue := { || ( oBrw:cAlias )->&( c ) }
aCols[ n ]:cHeader := c
aCols[ n ]:cEditPicture := "@!"
aCols[ n ]:nEditType := EDIT_LISTBOX
aCols[ n ]:nWidth := 120
aCols[ n ]:aEditListTxt := aEditListTxt
aCols[ n ]:aEditListBound := aEditListBound
aCols[ n ]:bOnPostEdit := { |o,v| ( oBrw:cAlias )->&( c ) := v }
return uRet
best regards
Wilson