Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange problem with Treeview SelectedItem property
Message
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00812987
Message ID:
00815112
Views:
24
>Hi Terry,
>
>>I agree - I think SelectedItem is just an imbedded mostly readonly
>>handle. I myself have never thought of it as a property that can be >assigned something.
>
>I think you're mixing up the Treeview.SelectedItem property itself and the object that it references.
A SelectedItem does not necessarily have it's selected property set to true. I can be false. In fact, unless a tree is absent of nodes, there will always be a SelectedItem.

There's obviously the equivalent of a VFP SelectedItem_Assign in there to prevent users assigning anthing other than a tree.node, .NULL. or .F. to it.
It is recommended that a NodeClick method set Selected to True: oNode.Selected=.t.

But when you access properties and methods of the .SelectedItem you are just accessing the node to which it refers and can manipulate it in exactly the same way as any Tree node.
SelectedItem is a reference to a node. The properties we 'think" we are manipulating really belong to the node it references, and not 'SelectedItem'.
Lets say we have a form, MyForm.
oform=MyForm
oform.caption="New Caption"
Are we modifying the caption of oform, or the caption of the object it references: MyForm?

>
>>I have also had problems with SelectedItem=.NULL.. It seemed to change [for >a while] the node's data type from object to a null!
>
Is this simply because the .SelectedItem property may be set implicitly (for example by mouseclick) by the treeview itself ?
Mouse click selections are one means, programmatic selection is another. When we SelectedItem=.NULL. we are changing the data type of a node from object to .NULL. Refreshing the tree with a mouseclick or Acitivate, returns the node to the Object state.

This can be demonstrated in code
cNodeKey=.SelectedItem.Key
.SelectedItem=.NULL.
?oNode(cNodeKey).Text && Data type error
The best way to deselect a selecteditem is
.SelectedItem.Selected=.f. This does not modify the data type. It's still an object. You can get rid of the 'ghost' row highlight bar by setting focus to a form control outside the tree.






>
>Regards,
>Viv
Imagination is more important than knowledge
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform