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
645
UltraGrid Hierarchical datasource as a collection
posted

Good afternoon.

Give, please, a code example, how to realize hierarchical datasource as a collection.

I attach a project that should work according to the instructions, but don't work correctly.

WindowsFormsApplication18.rar
Parents
  • 469350
    Offline posted

    Hi,

    I ran your sample project and it works just fine for me. My guess is that you just need to get the latest service release.

    How to get the latest service release - Infragistics Community

    In any case, I don't recommend using List<T> or binding the grid to an array like you are doing here. If you bind the grid to an Array or a List<T>, then you are using the IList interface, which is not a robust interface for data binding. You will have limited functionality in the grid if you use ILists.

    I recommend using BindingList<T>, instead.

    private void Form1_Load(object sender, EventArgs e)
            {
                A a = new A {Id = 1};
                B b = new B {Name = "b1", ParId = 1};
                a.Coll = new BindingList<B>{b};

                ultraGrid1.DataSource = new BindingList<A> { a };

                B b2 =new B{Name = "b2", ParId = 1};
                B b3 = new B { Name = "b3", ParId = 1 };
                a.Coll.Add(b2);
                a.Coll.Add(b3);
            }

            public class B
            {
                public int ParId { get; set; }
                public string Name { get; set; }
            }

            public class A
            {
                public int Id { get; set; }

                public BindingList<B> Coll { get; set; }
            }

    If you do that, it might work without the service release.

     

Reply Children