Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Recursive: See recursive
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01083365
Message ID:
01083840
Vues:
9
Rick,
See my replied within the text below.

>Einar,
>
>Couple of things.
>
>Just a suggestion: you're duplicating code by putting the foreach in both routines someone mentioned this before - you could just pass treeView.TopNode to RecursiveMethod, and the looping would would be encapsulated all within RecursiveMethod.

Yeah I know I should do that but I think it will be mostly to make it easier to read. Everything is encapsulated within the RecursiveMethod (in my oppinion that is).

>
>Second,
>
>
>if (treeNode.Id == foo.Id)
>
>
>There's no Id property of a tree node, so I'm guessing you're using something like the Tag property to hold the id of the record (or maybe you're using a third party treeview). In the old treeview, you could set a key, which had the benefit of being able to pass the key directly to the Nodes collection to get the exact node - I'll never understand why they stopped that.

The nodes of my tree are custom TreeNodes that inherit from System.Windows.Forms.TreeNode and my custom TreeNode has a property called Id (which happends to be a Guid) (I belive this better than the Tag property in the olden days as I can have multiple custom properties). The ability to pass a key (in my case Id) to the tree is exactly what I want to do with my recursive quest (why didn't I just say that to start with? lol)


>
>My final *g* suggestion would be to make TreeNode the return value of RecursiveMethod. When it finds the node, it returns the node, and if its not found, then return null. Its a little more useful and reusable that way: you're not burying what to do with the node inside the recursive method. You get a reference to the node you are looking for, and you can do whatever you want with it.
>
>
>TreeNode oFoundNode = RecursiveMethod(treeView.TopNode)
>if(oFoundNode!=null)
>{
>   oFoundNode.Selected=true;
>   oFoundNode.Font.Bold=true;
>}
>
Hmm I like your idea. I like it a lot, but I don't think it will work. Hmm on 2nd thought it might. (it is kind of hard to think because my kids will not leave me alone).

>
>>>It is not that I am really confused, but if I pretend to be more people are willing to help .
>
>Damn, tricked again! *g*

lol it works every time
>Rick

Thanks for your time Rick.

Einar
Semper ubi sub ubi.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform