侵犯选择节点

发布于 2025-01-28 10:02:22 字数 1160 浏览 3 评论 0原文

想知道我是错误还是我遇到了一个错误。

我和父母和孩子有一个网格。我已经制作了按钮将节点从上到下和背面移动。这有效,但是仍然选择了第一个选定的节点。应根据需要移动应移动的节点。为什么仍然显示第一个选定的节点?

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;
    }
}

所选节点如下所示:

”在此处输入图像描述”

---编辑:

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);
}

--- down_click_method相同

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:

enter image description here

---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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尬尬 2025-02-04 10:02:22

尝试以下代码:

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);
    }
}

上面代码中实现的逻辑非常简单。而不是移动所有选定的节点(例如加拿大…法国在下图上)上位于所有选定项目之前移动所有选定项目之前的第一个节点:

i.sstatic.net/9wai1.png“ rel =“ nofollow noreferrer ,在移动所有选定项目之前的节点后(在测试示例中,这是 巴西 item)ultratree控制将如下如下所示:

要正确确定所选项目的限制,应使用sortByposition()方法对其进行排序,该方法对selected> selected Nodes Collection进行分类。成员以在树上的顺序出现。

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:

enter image description here

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:

enter image description here

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文