'Infragistics Selected Node
Would like to know if I am the error or I have encountered a bug.
I have a grid with parents and children. I have made buttons to move the nodes from top to bottom and back. This works, but the first selected node remains selected. The node that should be moved can be moved as desired. Why is the first selected node still displayed?
private void IDC_ARROW_UP_Click(object sender, System.EventArgs e)
{
foreach (Infragistics.Win.UltraWinTree.UltraTreeNode Node in this.uTreeMenue.SelectedNodes)
{
Node.Reposition(Node, Infragistics.Win.UltraWinTree.NodePosition.Previous);
Node.Selected = true;
}
}
Selected node is shown below:
---EDIT:
private void IDC_ARROW_UP_Click(object sender, System.EventArgs e)
{
var NodeSelected = uTreeMenue.SelectedNodes;
var NodeCount = NodeSelected.Count;
NodeSelected.SortByPosition();
if (NodeCount > 0 && NodeSelected[0].PrevVisibleNode is Infragistics.Win.UltraWinTree.UltraTreeNode Node)
Node.Reposition(NodeSelected[NodeCount - 1], Infragistics.Win.UltraWinTree.NodePosition.Next);
}
---Same for the Down_Click_Method
Solution 1:[1]
Try the code below:
private void IDC_ARROW_UP_Click(object sender, System.EventArgs e)
{
var selected = uTreeMenue.SelectedNodes;
selected.SortByPosition();
var cnt = selected.Count;
if (cnt > 0 && selected[0].PrevVisibleNode is UltraTreeNode node)
{
node.Reposition(selected[cnt - 1], Infragistics.Win.UltraWinTree.NodePosition.Next);
}
}
The logic implemented in the code above is very simple. Instead of moving all selected nodes (for example Canada…France
on the picture below) up the first node located before all the selected items moving after all selected items down:
Therefore, after moving the node preceding all selected items down (in the test example this is Brazil
item) the UltraTree
control will be look like below:
To determine limits of the selected items correctly they are should be sorted by using the SortByPosition()
method, that sorts the SelectedNodes
collection such that members appear in the same order they do in the tree.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |