I found a solution to del a item from treview but it make error when I try to del a category
I have a dbf with two fields
DbCreate('GE', {{'GEMATERIA' , 'C', 40, 0} ,;
{'GEPCLAVE' , 'C', 45, 0} ,;
{'MAEJEMPL' , 'N', 5, 0}}, 'DBFCDX')
I have category and subcategory
category is tree first level (GEMATERIA)
subcategory is tree second level ( GEPCLAVE)
I made :
first del the record from dbf
local oLink := oTree:GetSelected()
local cPrompt := oLink:cPrompt
local cCargo := oLink:Cargo
local nRecno := GE->(Recno())
local lMateria := ( Len(cCargo) <= 40 )
local nNext
SELECT GE
GE->(DbSkip())
nNext := GE->(Recno())
GE->(DbGoto(nRecno))
GE->(DbDelete())
GE->(DbPack())
GE->(DbGoto(nNext))
IF GE->(EOF()) .or. nNext == nRecno
GE->(DbGoBottom())
ENDIF
now try to del the item on tree
oPadre := oLink:GetParent()
TVDeleteItem(oTree:hWnd, oLink:hItem )
nPosHijoenPadre := Ascan( oPadre:aItems, {|o| o:hItem == oLink:hItem } )
IF nPosHijoenPadre > 0
ADel ( oPadre:aItems, nPosHijoenPadre )
ASize( oPadre:aItems, Len(oPadre:aItems)-1 )
ENDIF
here run ok but only for subcategory
when I try to delete a category make error
- Code: Select all Expand view
Application
===========
Path and name: C:\Documents and Settings\Administrator\Desktop\tree\test.Exe (32 bits)
Size: 2,737,664 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20140725)
FiveWin Version: FWHX 15.01
Windows version: 5.1, Build 2600 Service Pack 3
Time from start: 0 hours 1 mins 13 secs
Error occurred at: 12/18/15, 10:06:55
Error description: Error BASE/1004 Class: 'NIL' has no exported method: AITEMS
Args:
[ 1] = U
Stack Calls
===========
Called from: => AITEMS( 0 )
Called from: test.prg => MABORRA( 244 )
Called from: test.prg => (b)TEST( 67 )
Called from: .\source\classes\BUTTON.PRG => TBUTTON:CLICK( 175 )
Called from: .\source\classes\CONTROL.PRG => TBUTTON:HANDLEEVENT( 1687 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3450 )
Called from: => SENDMESSAGE( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:COMMAND( 403 )
Called from: => TWINDOW:HANDLEEVENT( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 906 )
Called from: => DIALOGBOXINDIRECT( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 286 )
Called from: test.prg => TEST( 104 )