Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange problem with Treeview SelectedItem property
Message
 
To
23/07/2003 20:59:53
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00812987
Message ID:
00813341
Views:
8
It seems that VFP is saying that "THISFORM.Tree.Nodes(1)" is not an object.
messagebox(iif(type("THISFORM.Tree.Nodes(1).key")=="C",[Object],[Not Object]))

A couple of days back I was reading a thread regarding the issue of "un-selecting" or "de-selecting" a node. One offer suggested setting the node to .NULL.

I was using "selecteditem.selected=.f.". I swapped out the NULL node suggesting. It worked as advertized, and deselected the node. I cannot say if the ghost of the rowhighlight bar was there because de-selecting triggers an off control focus - that also removes the ghost.

Anyway - deselect worked great. However, when I tested some other sevices that programatically access the ocx, and the access involved the node set to NULL (as per that thread), VFP returned a data type error.

I switched back to "selecteditem.selected=.f."
do while type("oTv.selecteditem.key")=="C"
oTv.SelectedItem.Selected=.f.
enddo
And it worked!

>I have a form (run from EXE) where it's Init() prepares a treeview and a Listview for display.
>
>The Treeview is prepped by
THISFORM.Tree.ImageList=THISFORM.SmallIcons
>THISFORM.Tree.Filllist()
>
>THISFORM.Tree.SelectedItem = THISFORM.Tree.Nodes(1)
>followed by necessary code to do the same for the Listview.
>
>When this is executed, even though there is nowhere that the Tree.SelectedItem property is set in the Tree.FillList(), it runs without problem and the form displays nicely.
>
>Now here's the strange part...
>This form is one of several that are available from the application's File menu. Very standard stuff.
>When another form is run/closed and then THIS form is run the Init() fails on the line setting the Tree.SelectedItem node of the tree!#@#!@!#
>The error says there is a type mismatch.
>
>I understand the concept that certain variables can "hang around" and cause problems. But in this case the whole 'path' to the specific object is coded and it apparently has no problem executing the 2 lines prior that also refer to tree prop/meth!
>I even tried "ThisForm.tree.Object.SelectedItem..." with the same result.
>
>I'm sure that it is Selecteditem that is the problem because a few lines later I have the following coded:
THISFORM.List.Filllist(VAL(SUBSTR(THISFORM.Tree.selectedItem.Key,2)))
>*THISFORM.List.Filllist(VAL(SUBSTR(THISFORM.Tree.Nodes(1).Key,2)))
. When I comment out the earlier line using SelectedItem then it fails on the first line above, the error stating that Selecteditem did not evaluate to an object.
>Further, when I comment the lines with SelectedItem in them and UNcomment the line below it everything works as expected under all circumstances!!!
>
>However, this is not really a reasonable bypass for the problem at hand because when the Treeview has the SORT property set to .T. then it is most likely that Node(1) will NOT be the item that IS selected, resulting in the WRONG INFORMATION being shown in the Listview.
>
>Can someone suggest what I can do to prevent this?
>
>Thanks
Imagination is more important than knowledge
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform