We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Binding Complex Object Collections to Grid?

Hi, I''ve just downloaded the trial version of the Essential grid and am unsure which way to best approach my problem. Here is the issue: I have a ObjectCollection that implements IBindingList. The ObjectCollection contains ClassA objects. ClassA has a property that is a ClassB object. In the Grid I would like to have columns for the following: ClassA.Prop1, ClassA.Prop2, ClassA.ClassB.Prop1, ClassA.ClassB.Prop2 The System.Windows.Forms.DataGrid cannot do this because you can only have 1 DataSource for the grid (ClassA) and the MappingName''s for the columns must be properties of that DataSource (ie. ClassB and not ClassB.Prop1). Here are the 3 ways which I see this could work with the EssentialGrid, please tell me what is the best choice. 1) Use databound cells, iterate through my entire collection and set up the databindings for each cell individually. 2) Use the virtual grid and write the QueryCellInfo/SaveCellInfo handlers. 3) Use the GridDataBoundGrid - how? Does it have the same limitations as the .NET DataGrid wrt MappingName''s? Seems like option 3 would be best if it is possible, but I don''t want to sink a lot of time into it if it won''t work. Thanks in advance for your assistance. Regards, Daws

2 Replies

AD Administrator Syncfusion Team March 23, 2004 01:02 PM UTC

You will not be able to just set properties and get this to work using any of our grids. Below is one solution that using a GridDataBoundGrid and QueryCellInfo/SaveCellInfo to handle this problem. It uses a ITypedList implementation on the main collection to make things a little more general. You could simplify things (in the short run) by hard coding things, but using the typedlist shows how you might handle it in a more general way. 9406_742.zip


DA Daws March 23, 2004 01:19 PM UTC

Thanks for the quick response. I can already see how this is going to work very nicely. Regards, Daws

Loader.
Live Chat Icon For mobile
Up arrow icon