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.
Thanks for the Suggestion
Hi,
I'm not sure what you are asking. What do you mean by "an excess column?" The grid will show all of the fields that exist in the DataSource you bind to. If you don't want to show a particular field in the grid, then you have a number of options.
You could choose not to include that field in your DataSource.
You could mark that field Browsable[false].
Or you could simply hide the grid column using the hidden property.
Mike,
thanks for the quick reply.
My problem is: if I add a field to the "B" class, then an excess column appears in the grid, though I don't want it to appear. Changing List to BindingList doesn't help here.
How to improve the situation?
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.