I have to do a combobox check where I select the major categories and then I have to refresh another combobox with the lower categories corresponding to the major category selected.
when I go to reload the lower categories in the second combobox control it gives me an error
this is the test
- Code: Select all Expand view
- #include "FiveWin.ch"
#include "Constant.ch"
request dbfcdx
Function test_reload_combo()
local nBottom:= 22
local nRight := 55
local nHt := nBottom * DLG_CHARPIX_H
local nWd := Max( nRight * DLG_CHARPIX_W, 180 )
local aget:=array(10)
local oSay:=array(10)
local oFont,oBold
local nMode:= 1,n
local aCategorie:=TCategorie():GetList()
local aSubCategorie:={{"","nessuna"}}
local cCategoria := aCategorie[ 1 ][2]
local cSubCategoria,npos
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-12 BOLD
DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL;
TITLE "test"
@ 10, 10 SAY oSay[5] PROMPT "categoria" SIZE 150,25 PIXEL OF oDlg TRANSPARENT FONT oFont
@ 10, 150 COMBOBOX aGet[5] VAR cCategoria Items ArrTranspose(aCategorie )[ 2] size 240,120 PIXEL OF oDlg FONT oFont HEIGHTGET 20 ;
ON CHANGE ( n:=aGet[5]:nat, ReloadCombo(@aSubCategorie,cCategoria, aCategorie[n][1] ),;
oSay[6]:show(),;
aget[6]:show(),;
aGet[6]:setItems(aSubCategorie),;
If(nMode==1,aGet[6]:Select( 1 ),;
( nPos := AAT( aSubCategorie, cCategoria),aGet[5]:Select( nPos ))),;
aGet[5]:refresh())
@ 60, 10 SAY oSay[6] PROMPT "Sottocategoria" SIZE 150,25 PIXEL OF oDlg TRANSPARENT FONT oFont
@ 60, 150 COMBOBOX aget[6] VAR cSubCategoria Items ArrTranspose(aSubCategorie )[ 2] size 240,90 PIXEL OF oDlg HEIGHTGET 20
ACTIVATE DIALOG oDLG CENTERED;
ON INIT (oSay[6]:hide(),aget[6]:hide())
RETURN NIL
Function Categorie()
Msginfo("add cat")
return nil
static Function ReloadCombo(aItems,cCategoria,cCodcat)
local nArea := Select()
local cFilter := "(CodCatM1) == '" + cCodcat + "' .and. !Empty(FIELD->CodCatM2)"
local oList:= TCategorie():new()
asize( aItems, 0 )
oList:setorder(2)
oList:setFilter(cfilter)
oList:Gotop()
xbrowser oList
AaDd(aItems,{"","nessuna" })
Do while !oList:eof()
AAdd( aItems, {oList:CodCatM2,oList:DESCRCATM })
oList:Skip()
EndDo
oList:close()
Select (nArea)
return aItems
//------------------------------------------------------------------------//
CLASS TXData from TDatabase
DATA cDbfPath init ".\data\"
ENDCLASS
CLASS TCategorie from TXData
METHOD New()
METHOD GetList()
ENDCLASS
METHOD New( lShared ) CLASS TCategorie
Default lShared := .t.
::super:New(,::cDbfPath+"Categorie" ,"DBFCDX", lShared)
if ::use()
::setOrder(1)
::gotop()
endif
RETURN Self
METHOD GetList() CLASS TCategorie
local aTemp:={}
local cFilter:= "Empty(FIELD->CodCatM2)"
local oList
local nArea := Select()
oList:= TCategorie():new()
oList:SetFilter(cFilter)
oList:gotop()
AaDd(atemp,{"", "Predefinita" })
DO While !oList:eof()
AaDd(atemp,{ oList:CodCatM1,TRIM(oList:DESCRCATM) })
oList:skip()
ENDDO
AaDd(atemp,{ "","aggiungi" })
Select (nArea)
oList:close()
return aTemp
If you want the dbf I can sent you via mail
Both categories and subcategories must have two array elements
in the first there is the category code
in the second there is the description of the category
When show the second combobox the exe crash out
- Code: Select all Expand view
- Application Internal Error - C:\Work\errori\test_categorie\test2.Exe
Terminated at: 2024-04-30 09:22:51
Unrecoverable error 6005: Exception error:
Exception Code:C0000005 ACCESS_VIOLATION
Exception Address:778D7685
EAX:01184D70 EBX:00000000 ECX:00000000 EDX:00000002
ESI:00000000 EDI:01176E78 EBP:00F5D134
CS:EIP:0023:778D7685 SS:ESP:002B:00F5D0E8
DS:002B ES:002B FS:0053 GS:002B
Flags:00010206
Exception Parameters: 00000000 00000000
CS:EIP: 66 8B 06 83 C6 02 66 3B C1 75 F5 2B F2 8D 45 D4
SS:ESP: 00000000 01176E78 00000001 00000001 016C3744 00000000 00000000 00000008 00B9742C 00000000 00000000 00000000 00ACDEA7 00B9742C 00000064 00000000
C stack:
EIP: EBP: Frame: OldEBP, RetAddr, Params...
778D7685 00F5D134 00F5D1CC 778D6A32 01176E78 00000000 00000004 01ADE580 00000180 00000000 01602A5C 00000000
778D6A32 00F5D1CC 00F5D1F8 778D6092 01ADE580 00000000 00000180 00000001 00000000 00000000 0035035C 00000180
778D6092 00F5D1F8 00F5D224 778A177B 0035035C 00000180 00000001 00000000 0035035C DCBAABCD 77D27FB0 00000180
778A177B 00F5D224 00F5D30C 77897B6A 77D27FB0 0035035C 00000180 00000001 00000000 500566A8 40000000 C0000388
77897B6A 00F5D30C 00F5D370 7789776A 77D27FB0 00000000 00000180 00000001 00000000 00D73000 00000001 500566D4
7789776A 00F5D370 00F5D3B0 778F3A46 01ADE580 00000000 00000180 00000001 00000000 77D27FB0 00000180 778A31A0
778F3A46 00F5D3B0 00F5D468 77D1507D 00F5D3CC 00000038 00F5D630 77D14FB0 00F5D408 00000068 00000008 00000000
77D1507D 00F5D468 00F5D500 778C0C13 01ADE580 00000000 00000000 00000001 01ADE430 00000143 00000000 50056130
778C0C13 00F5D500 00F5D52C 778C076B 01ADE430 00000000 00000143 00000001 00000000 00000001 000F05A2 00000143
778C076B 00F5D52C 00F5D558 778A177B 000F05A2 00000143 00000001 00000000 000F05A2 DCBAABCD 77D27F80 00000143
778A177B 00F5D558 00F5D640 77897B6A 77D27F80 000F05A2 00000143 00000001 00000000 500563E4 77D27F80 01ADE430
77897B6A 00F5D640 00F5D678 77897326 77D27F80 00000000 00000143 00000001 00000000 00000000 00000000 00000001
77897326 00F5D678 00F5D690 778843BB 00000143 00000001 00000000 00000001
778843BB 00F5D690 00F5D6B8 007DA446 77D27F80 000F05A2 00000143 00000001 00000000 00000143 000F05A2 000F05A2
007DA446 00F5D6B8 00F5D6D8 0081A6EF 000F05A2 00000143 00000001 00000000 00000005 0081A6D0
0081A6EF 00F5D6D8 00F5D704 778A177B 000F05A2 00000143 00000001 00000000 000F05A2 DCBAABCD 0081A6D0 00000143
778A177B 00F5D704 00F5D7EC 77897B6A 0081A6D0 000F05A2 00000143 00000001 00000000 50056248 00000143 00000000
77897B6A 00F5D7EC 00F5D850 77898A99 0081A6D0 00000000 00000143 00000001 00000000 00D73000 00000001 00000143
77898A99 00F5D850 00F5D870 7788453D 01ADE430 00000000 00000000 00000001 00000000 00000000
If I use one dimension for second combobox then run ok But I need two elements