Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to tell if a node exists in a treeview
Message
De
30/11/2001 14:25:40
Alexandre Palma
Harms Software, Inc.
Alverca, Portugal
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00588046
Message ID:
00588189
Vues:
22
This message has been marked as the solution to the initial question of the thread.
Sorry Roi if you if you do vartype you will get an error but if you do TYPE has I said then if the SelectKey is invalid type will return U so try the following:
IF TYPE('This.Nodes[SelectedKey]') = 'O'
   This.SelectedItem = This.Nodes[SelectedKey]
ENDIF
>Nope, This.Nodes is a method that returns an object. The SelectedKey is just a string for the index key. If the index key references a non existant node an error occurs. That's my problem. I need to know if the object exists in the collection prior to calling This.Nodes.
>
>>Roi and how about TYPE('This.Nodes[SelectedKey]') This should work.
>>
>>>Same deal, This.Nodes[SelectedKey] causes and error. I think I just have to catch the error and go from there.
>>>
>>>>Sorry try this one:
>>>>>I have a method that rebuilds all the nodes in a treeview.
>>>>>
>>>>>I save the currently selected node with:
>>>>>
SelectedKey = This.SelectedItem.Key
>>>>>
>>>>>Then I clear all the nodes and rebuild the tree.
>>>>>
>>>>>Then I want to reselect the Selected item with:
>>>>>
This.SelectedItem = This.Nodes[SelectedKey]
>>>>>This.SelectedItem.ensurevisible
>>>>>
>>>>>However sometimes the SelectedKey doesn't exist once the tree is rebuilt. Is there an easy way to determine that? I can't spin through all the keys because I build each branch dynamically as it is expanded. The only thing I've can think of is setting it, catching the error if it doesn't exist, and going on from there.
>>>>>
>>>>>tia
Alexandre Palma
Senior Application Architect
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform