Hi,
When a bind data with ICollection property and Count = 0 I can Initialize my column
ugrdAddressMailling.DataSource = Customer.AddressMailling;
But If I bind with List<t> and count = 0 I can Initialize them.
ugrdAddressMailling.DataSource = Customer.AddressMailling.ToList()
There are solution to initialize my columns with ICollection when the count is 0 ?
Hello Francois,
Thank you for posting in our forum.
I have tested this behavior and both with ICollection and with List UltraGrid initialize its columns. In the attached archive I am sending you the project I have tested this with to test it on your side. Please let me know if you face the same issue with my sample. Note that it was built with the latest version of Infragistics Controls for Windows Forms 15.2. So please let me know which the exact version you are using is.
Can you give me and some more information about Customer.AddressMailing class? What is the type of the AddressMailing property? I understand this is ICollection of some objects, but what is the actual type of this collection – is this a List, BindingList or some other collection implementing ICollection interface.
Looking forward to your reply.
Thank you for using Infragistics Controls.
Hi Miko,
I use EntityFramework and he initialize my ICollection with new HashSet
Replace on your code
this
ICollection<SampleObject> data = new List<SampleObject>();
for this
ICollection<SampleObject> data = new HashSet<SampleObject>();
Francois.
Hi Francois,
The WinGrid (and Winforms controls in general) use either IList or IBindingList. The fact that, at one point, you happen to be casting it to an ICollection interface is irrelevant here - neither the grid nor the DotNet BindingManager will use it. If you use:
ICollection data = new List();
Then you are binding the grid to a List, and it implements IList and so it works.
If you use:
ICollection data = new HashSet();
This will not work correctly because you are binding the grid to a HashSet does not implement IList or IBindingList and is therefore not an appropriate DataSource for a WinGrid (or likely any other WinForms control).
To demonstrate this, I tried the same thing with the DataGridView control and I get exactly the same results.
Ok Thank you.
Francois