lets say im binding a tree to a dataset.
Is there a way to say that the KEY of the node will be This Column of the DataTable .... ?
You could do something like this:
private void ultraTree1_InitializeDataNode(object sender, InitializeDataNodeEventArgs e) { e.Node.Key = e.Node.Cells["Key Field"].Text; }
the only problem with this is that the handler is called when the tree loads ..... I'm using a texteditor with ButtonRight = DropDown ... and using the Tree as Control.
So In the BeforeEditorDropDown event I need to select the Node base on the textEditor value, and the only way I found to find a Node is GetNodeByKey.
But the BeforeEditorDropDown is called before the InitializeDataNode .......
If using GetNodeByKey is working and returning the correct node, set the Selected property on that node. If you are trying to match the node's Text with the text editor's value, you have to recursively iterate the nodes and manually compare the value of the Text property to the value in the text editor.
I get what you say. I do use the Selected property.
The real problem is that the event BeforeEditorButtonDropDown is called BEFORE the InitializeDataNode (where I want to set the Key of the node to a specific column of the DataTable)
InitializeDataNode gets called when the node is created from the data source. My guess is that since your tree is not visible, it's not firing until the first time the tree paints and creates the nodes.
If that's true, all you need to do is call tree.Refresh to force the tree to paint and it will fire the InitializeDataNode at that point.
Hm, that's off. This might be a problem with the BindingManager, then. I have noticed in the past that the BindingManager does not update controls that have not yet had their handle created. If that's the case, I'm not sure what you could do about it.
Perhaps instead of calling GetNodeByKey directly from the event, you could use a BeginInvoke to call a method that does it. This should introduce a small delay in the execution of the code and the tree should have populated itself by the time the method is called.
If that doesn't work, I recommend that you create a small sample project demonstrating the issue and Submit an incident to Infragistics Developer Support so they can check it out and see what's going on.
It's true,
I tried (just for test) to call tree.Refresh in the BeforeEditorButtonDropDown before doing a GetNodeByKey. I notice that the tree.Refresh does not at all fire the InitializeDataNode