Completed
Last Updated: 13 Dec 2014 07:51 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 21 Oct 2014 12:01
Category: TreeView
Type: Bug Report
1
FIX. RadTreeView - ArgumentOutOfRangeException when deleting nodes with same text in a sorted treeview
To reproduce: add a RadTreeView and a RadButton to the form. Use the following code snippet:

public Form1()
{
    InitializeComponent();

    RadTreeNode node1 = new RadTreeNode();
    node1.Text = "SameText";

    RadTreeNode node2 = new RadTreeNode();
    node2.Text = "SameText";

    this.radTreeView1.Nodes.Add(node1);
    this.radTreeView1.Nodes.Add(node2);

    this.radTreeView1.SortOrder = SortOrder.Ascending;
}

private void radButton1_Click(object sender, EventArgs e)
{
    for (int i = this.radTreeView1.Nodes.Count - 1; i > -1; i--)
    {
        this.radTreeView1.Nodes.RemoveAt(i);
    }
}

Workaround: set the SortOrder property to None before removing the nodes and restore it afterwards

private void radButton1_Click(object sender, EventArgs e)
{
    this.radTreeView1.SortOrder = SortOrder.None;
    for (int i = this.radTreeView1.Nodes.Count - 1; i > -1; i--)
    {
        this.radTreeView1.Nodes.RemoveAt(i);
    }
    this.radTreeView1.SortOrder = SortOrder.None;
}
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
0 comments