I need to know how in code to select a treenode in the ultratree control so that node is shown selected to the user.. Does the ultratree have a method which takes as an input parameter the treenode’s key and selects that node so that node is shown as selected in the ultratree control to the user?
Hello Sfrierdi,
Maybe you are looking for the method:
UltraTreeNode MyNode = ultraTree1.GetNodeByKey("KEY");
About the selected nodes you could try this snippet code
ultraTree1.HideSelection = false;
ultraTree1.ActiveNode = MyNode;
ultraTree1.ActiveNode.Selected = true;
Please take a look in our online documentation for more details:
http://help.infragistics.com/Help/NetAdvantage/WinForms/2011.1/CLR2.0/html/WinTree_Navigation_and_Selection.html
Please let me know if you have any questions.
Regards
Hello Sfriedi,
Have you been able to resolve your issue ? Please if you have any questions, do not hesitate to write us.
Yes I was able to solve the problem thanks
I'm also having an issue with getting the active node selected. code snippet:
UltraTreeNode anode = utMain.GetNodeByKey(nid.ToString()); utMain.HideSelection = false; utMain.ActiveNode = anode; utMain.ActiveNode.Selected = true; utMain.ActiveNode.BringIntoView(true); LoadRecord(nid);
while the tree does expand the proper nodes, the selected node is staying on the one that fired this and is showing as the highlighted node
also verified, as the afterselect event is not firing which actually loads that node record.
Hello James,
I try to reproduce your issue using the code below, but without success.
UltraTreeNode anode = ultraTree1.GetNodeFromPoint(e.X, e.Y);
ultraTree1.HideSelection =false;
anode.Override.ActiveNodeAppearance.BackColor =Color.OrangeRed;
ultraTree1.ActiveNode = anode;
ultraTree1.ActiveNode.Selected =true;
ultraTree1.ActiveNode.BringIntoView(true);
//LoadRecord(nid);
I suppose that maybe something into your code override these settings (maybe your LoadRecord() method) or if you have AppStyle into your application. Are you able to upload small sample that reproduce your issue and I`ll be glad to research it for you.
Let me know if you have any questions
I finally got this working, and it was partially the way the controls were set up. The tree composed of "books" and then documents under those books. Documents could become a Parent if a document was dragged onto another document. Part of the issue was I was dynamically loading the documents each time a book was clicked on, but not loading the others (was for a help documentation manager basically with documentation from multiple applications). I worked around the issue by backloading other books (and children) upon requirements and that solved the issue.
private void FindRecordInTree(int nid,string link) {//get the bookid DataTable ttable = Requests.SQLGen.ProcessSQLCommand(gobj, "Select Book, ParentID from AxisDoc where ID = " + nid, true); if (ttable == null || ttable.Rows.Count == 0) { MessageBox.Show("Error in link Destination '" + link + "'"); }//expand the nodes foreach (UltraTreeNode znode in utMain.Nodes) { if (TagName(znode.Tag) == (int)ttable.Rows[0][0]) { //tagname gets the key of the document LoadDocs(znode); znode.Expanded = true; } } UltraTreeNode anode = utMain.GetNodeByKey(nid.ToString()); utMain.SelectedNodes.Clear(); anode.BringIntoView(); utMain.ActiveNode = anode; anode.Selected = true; }