Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ole idispatch error: element not found
Message
From
09/01/2007 11:29:34
 
 
To
08/01/2007 20:39:17
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6
Miscellaneous
Thread ID:
01183672
Message ID:
01183821
Views:
18
Perhaps item with key from your "crelative" field is not added to treeview. Treeview can add child elements only for existing parent elements. You may use recursive procedure to force adding parent elements before their children regardless of records order in a table. Something like that:
FUNCTION AddChildren
LPARAMETERS tcParent

LOCAL lnOldRec
m.lnOldRec = RECNO() &&Save current record

SCAN FOR ALLTRIM(crelative) == m.tcParent
  o.Add(alltrim(crelative),4,alltrim(ckey), alltrim(ctext),0)
  AddChildren(alltrim(ckey))
ENDSCAN

GOTO m.lnOldRec &&Restore current record for scan loop in calling function
ENDFUNC
And of course some customized function is needed to add root level elements:
FUNCTION AddRootElements

SCAN FOR crelative = '0'
  o.add(,1,alltrim(ckey),alltrim(ctext),0)
  AddChildren(alltrim(ckey))
ENDSCAN
ENDFUNC
>Why do I get an error OLE IDispatch exception code 0 from Nodes: Element not found?
>
>This is the code:
>
>
>sele treeview
>set multilocks on
>=cursorsetprop("buffering",5,"treeview")
>
>sele treeview
>=tableupdate(.t.)
>go top
>o = thisform.oletreeview.nodes
>o.clear
>
>scan
>	if alltrim(crelative) = '0'
>		o.add(,1,alltrim(ckey),alltrim(ctext),0)
>	else
>erro >>>        o.add(alltrim(crelative),4,alltrim(ckey), alltrim(ctext),0)
>	endif
>endscan
>
>thisform.oletreeview.selecteditem = thisform.oletreeview.nodes(1)
>
>thisform.updateproperties(thisform.oletreeview.selecteditem)
>
>if loexpand=0
>	loexpand=1
>else
>	thisform.cmdexpandcollapse.click
>endif
>
>
>Please help me. TIA.
/A new technology turns into completely outdated stuff before you have a time to read "Getting Started..." section.
/If there are some "system programmers" then others are unsystematic.
Previous
Reply
Map
View

Click here to load this message in the networking platform