Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange problem with Treeview SelectedItem property
Message
From
26/07/2003 08:36:36
 
 
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00812987
Message ID:
00813737
Views:
13
Viv,
While we're getting nowhere, I reply to clarify further (obviously my thread-started was UNclear)...

I had the line:
THISFORM.List.Filllist(VAL(SUBSTR(THISFORM.Tree.selectedItem.Key,2)))
as the ONLY line in the code referring to .SelectedItem and all was fine until a specific OTHER form was run, and subsequent rerunning of THIS form resulting in an error on the line above that .SelectedItem does not evaluate to an object.

I thought that was strange and couldn't see why that would be the case, so as an attempted workaround I added the line:
THISFORM.Tree.SelectedItem = THISFORM.Tree.Nodes(1)
to the Treeview's setup section just above. Again all was fine UNTIL that OTHER form had been run previously, in which case THIS TIME it errored on the line I had just added, this time as a "type mismatch".

Now, as regards my last reply to you...
In a further attempt at bypassing the error I replaced the last line shown above with:
ThisForm.Tree.Nodes(1).Selected = .T.
and this has apparently caused the .SelectedItem property of the Treeview to NOW have a legitimate value under ALL circumstances including the case that THIS form is rerun after the problem-causing form has been run.
As you can see for yourself in the line above, .Nodes(1) *IS* correctly resolved.

Now this bypass evades the problem, but with the unpleasant unnatural consequence that the node that appears as selected (highlighted) is NOT the first in the Tree (.SORTED causes it to appear third, as luck would have it).

SUMMARY:
On the assumption that the Treeview's initial presentation defaults to always highlighting the FIRST displayed node (and further assuming that ANY highlighted node is the .SelectedItem node) I had a line of code that attempted to refer to that node using "VAL(SUBSTR(THISFORM.Tree.selectedItem.Key,2))" as the parameter for the method that fills the coresponding Listview.
This worked correctly repeatedly UNTIL a specific other form was run (and exited) and this form was re-run, in which case it errored with '.SelectedItem does not evaluate to an object'.

I hope this is clearer now.

JimN

>Hi Jim,
>
>
>THISFORM.Tree.SelectedItem = THISFORM.Tree.Nodes(1)
>
>
>In re-reading your original post it sounds to me as if ThisForm.Tree.Nodes(1) is the item that is, for some reason, not an object? .SelectedItem will accept a node object or a logical value (as long as it's false) and it looks as if it's not getting either.
>
>I still think your chances of solving this will be much improved if you are *sure* of the source of the error.
>
>If you can't use ASSERTS then why not a message box:
>

>IF TYPE("THISFORM.Tree.Nodes(1)") <> "O"
> = messagebox("Node not an object")
>ENDIF
>

>
>Regards,
>Viv
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform