Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange problem with Treeview SelectedItem property
Message
From
24/07/2003 20:35:45
 
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00812987
Message ID:
00813356
Views:
7
While I see what you're getting at Terry, I don't think I can use Selected=.T. in this case because after it is SORTed node index #1 could be anywhere. I need to highlight the FIRST SHOWN item (which the Treview seems to do nicely, all by itself) and then use its .Key to fill the Listview with the corresponding information.

By the way, FYI, it was also a reply here (by Cathy Pountney, I think) that sent me in the direction of SelectedItem to handily solve this problem. In fact I've gotta believe that it is just this problem that caused the designers to make that property.

In addition, if you look at the commented line in the last code sample I show, it refers to
...Node(1).Key and that does NOT fail, so I don't think it is the Node(1) that is the problem.

What I REALLY need is to get an idea as to what it might be about some OTHER form's prior execution that might be messing up the .SelectedItem usage (as I said, it works just fine until another form is run, then .SelectedItem fails every time).

Thanks for the input. Any further ideas gratefully considered.


>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform