Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
235
Exception when removing last item from a Binding List
posted

Hi all,

Version: 10.3.20103.1000

A have a UltraTree bound to a BindingList<T>. If I remove the last item from the binding list to create an empty list, then the tree control throws the following exception.

Infragistics2.Win.UltraWinTree.v10.3.dll!Infragistics.Win.UltraWinTree.TreeNodesCollection.GetNodeFromListIndex(int listIndex = 0) + 0x23 bytes Infragistics2.Win.UltraWinTree.v10.3.dll!Infragistics.Win.UltraWinTree.TreeNodesCollection.dataList_ItemDeleted(System.ComponentModel.ListChangedEventArgs e) + 0x15 bytes Infragistics2.Win.UltraWinTree.v10.3.dll!Infragistics.Win.UltraWinTree.TreeNodesCollection.dataList_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e) + 0x2a bytes UltraTreeBinding.exe!UltraTreeBinding.Form1.Button1Click(object sender = {Text = "Remove Node"}, System.EventArgs e = {X = 49 Y = 8 Button = Left}) Line 58 + 0x12 bytes C#

If I replace the final Remove with a Clear(), then everything works fine. Can you take a look to see if this is a bug in the tree control?

Thanks

Steve

 

Sample code:

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace UltraTreeBinding
{    
    public partial class Form1 : Form
    {
        private readonly BindingList dataSource = new BindingList();
        private Infragistics.Win.UltraWinTree.UltraTree ultraTree1;
        private Button button1;

        /// 
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// 
        private void InitializeComponent()
        {
            ultraTree1 = new Infragistics.Win.UltraWinTree.UltraTree();
            button1 = new Button();
            ((ISupportInitialize)(ultraTree1)).BeginInit();
            SuspendLayout();
            
            // ultraTree1
            ultraTree1.Dock = DockStyle.Top;
            ultraTree1.Size = new Size(550, 350);
            ultraTree1.Name = "ultraTree1";
            
            // button1
            button1.Location = new Point(13, 370);
            button1.Size = new Size(75, 23);
            button1.Text = @"Remove Node";
            button1.Click += Button1Click;
            
            // Form1
            AutoScaleDimensions = new SizeF(6F, 13F);
            AutoScaleMode = AutoScaleMode.Font;
            ClientSize = new Size(551, 411);
            Controls.Add(button1);
            Controls.Add(ultraTree1);
            ((ISupportInitialize)(ultraTree1)).EndInit();
            ResumeLayout(false);
        }

        public Form1()
        {
            InitializeComponent();

            dataSource.Add("Node 1");
            dataSource.Add("Node 2");

            ultraTree1.DataSource = dataSource;
        }

        private void Button1Click(object sender, EventArgs e)
        {
            dataSource.RemoveAt(0);
        }
    }
}