If I select first combo I can select a Province sample "TE" and it reload the second Combobox with all cities of this province "TE"
as you can see in this picture :
then I can save all data into a dbf good
the problem is at Init
1. when on modify I set the combo value with cstring
cProvincia := RU->RUPRV
cComune := RU->RULOC
while I can see the first combo with the value ( see the picture ) on second combobox I not see the value ....
2. the second problem is I can see the first combobox value but if I select with the mouse on the second combobox I cannot select any items
I must click on first combo and reselect the province , then it reload the aitems of second combobox
this is the test sorce code :
- Code: Select all Expand view
#Include "Fivewin.ch"
REQUEST DBFCDX
REQUEST DBFFPT
EXTERNAL ordkeyno, ordkeycount,ordcreate,ordkeygoto
Function Main()
Local oFrmVds, oCbx1, oCbx2
LOCAL aPROVINCE:={}
LOCAL aCOMUNI:={}
local cProvincia := ""
local cComune := ""
RddSetDefault( "DBFCDX" )
USE COMUNI ALIAS COMUNI
INDEX ON COMUNI->PROVINCIA TAG PROV TO COMUNI // Sure you don´t need to create this index every time
USE PROVINCE ALIAS PROVINCE
index on PROVINCE->SIGLA tag prov to PROVINCE
DO WHILE ! PROVINCE->(EoF())
AAdd( aPROVINCE,( TRIM(PROVINCE->SIGLA)))
PROVINCE->(DbSkip())
ENDDO
CLOSE PROVINCE
if ! Db_Open("RUX","RU")
return nil
endif
cProvincia := RU->RUPRV
cComune := RU->RULOC
Define DIALOG oFrmVds TITLE " TEST COMUNI " ;
FROM 452, 774 to 950, 1539 PIXEL
@ 82, 11 SAY "Provincia di nascita :" SIZE 55, 7 PIXEL OF oFrmVds COLOR 0, 14215660
@ 81, 61 COMBOBOX oCbx1 VAR cProvincia ITEMS aPROVINCE SIZE 30, 90 PIXEL OF oFrmVds COLOR 0, 16777215 ;
ON CHANGE Reload(@oCbx2, @aComuni, cProvincia)
@ 82, 95 SAY "Comune di nascita :" SIZE 55, 7 PIXEL OF oFrmVds COLOR 0, 14215660
@ 81, 165 COMBOBOX oCbx2 VAR cComune ITEMS aComuni SIZE 100, 80 PIXEL OF oFrmVds COLOR 0, 16777215
@ 205, 168 BUTTON oBtn PROMPT "Conferma" OF oFrmVds SIZE 40, 10 PIXEL DEFAULT ACTION ( oFrmVds:end( IDOK ) )
@ 205, 212 BUTTON oBtn PROMPT "Annulla" OF oFrmVds SIZE 40, 10 PIXEL CANCEL ACTION ( oFrmVds:end( IDCANCEL ) )
ACTIVATE DIALOG oFrmVds RESIZE16 CENTERED ON INIT (oCbx1:bCloseUp:=oCbx1:bChange)
if oFrmVds:nresult == IDOK
Replace RU->RULOC with cComune
Replace RU->RUPRV with cProvincia
endif
RETURN NIL
// Function to reload the second combobox
Static Function Reload(oCbx, aItems, cProv)
aItems:={}
USE COMUNI ALIAS COMUNI NEW
Comuni->(DbSetFilter({|| Comuni->Provincia==cProv}))
Comuni->(DbGoTop())
OutputDebugString("Reloading Comuni for Prov. "+cProv)
Do While Comuni->(!Eof())
AAdd( aItems, RTrim(Comuni->Localita))
Comuni->(DbSkip())
EndDo
OutputDebugString("Reloaded " +Str(Len(aItems))+" Comuni for Prov. "+cProv)
oCbx:SetItems(aItems)
CLOSE Comuni
return .t.
function Db_Open(cDbf,cAlias)
USE &(cDbf+".dbf") ;
INDEX &(cDbf+".cdx") ;
ALIAS &(cAlias) NEW
return .t.
If you want dbfs I can send you because are big !!!