Key in node collection

I need to have a key value and a display value for my iconic node, so that more than one node can have the same display text. The problem is that when I add the node to the document node collection it uses the text as the "key" value, so the following code: goIconicNode.Text = myKey;
goIconicNode.Label.Text = myText; always results in the node being stored with myText as the key rather than the real key (myKey). Is there any way of accomplishing what I want? Thanks. Marek

GoIconicNode.Text is (by default) defined to be the same as GoIconicNode.Label.Text for both getting and setting, which is why you see that behavior.
I assume you don’t want the key to be seen by users as the text of the label. If that is the case, you can just store the key in some other property. Using the GoNode.UserObject property is common–it’s the equivalent of the Tag property for some other WinForms classes. Or you can store it in your own property that you define in a subclass of GoIconicNode. There are examples of this in the User Guide and in the samples.

Hi Walter
Thanks for the reply. I just wanted to call GoView.Document.Find(Key) and get the node back. I guess I will just have to iterate over the collection of objects myself and find the one I need using the UserObject as you suggest. A bit of a shame.
Thanks again.

You might want to maintain your own hash table, so that you can look up nodes by key efficiently, if that is a consideration in your application. Then you can implement a GoDocument.Changed event handler that checks for the GoLayer.InsertedObject and GoLayer.RemovedObject hints to keep the hash table up-to-date.