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)))
. 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 line
s 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