An array list can be directly bound to the data source of the Grid Grouping control.
Features:
An array list that can be directly bound to the data source of a Grid Grouping control
An object that has information for each column added for each item in the array list
A relationship between tables established by the grid relation descriptor's UniformChildList
ArrayList al = new ArrayList(); al.Add(new ParentItem("Condiments", "Charlotte Cooper","Bigfoot Breweries", cl1)); al.Add(new ParentItem("Confections", "Regina Murphy","Grandma Kelly's Homestead",cl2)); al.Add(new ParentItem("Grains/Cereals","Jean-Guy Lauzon","Ma Maison", cl3)); al.Add(new ParentItem("Meat/Poultry","Shelley Burke","New Orleans Cajun Delights", cl4)); al.Add(new ParentItem("Produce", "Mayumi Ohno","Mayumi's",cl5)); al.Add(new ParentItem("Seafood","Robb Merchant","New England Seafood Cannery", cl6)); this.gridGroupingControl1.DataSource = al;
For each item present in an array list, an object with information for each column is added.
public class ParentItem { string name; ChildList child; public string CategoryName { get{return name;} set{name = value;} } public string SupplierName { get{return supplier_name;} set{supplier_name = value;} } public string CompanyName { get{return company_name;} set{company_name = value;} } public ChildList Child { get{return child;} set{child = value;} } public ParentItem():this("","","",null) { } public ParentItem(string name ,string sname,string cname,ChildList dt) { this.name = name; this.supplier_name = sname; this.company_name = cname; this.child = dt; } }
A relation between the tables is established by the grid relation descriptor's UniformChildList.
// Binding the child table. GridRelationDescriptor grd = new GridRelationDescriptor(); grd.RelationKind = RelationKind.UniformChildList; grd.MappingName = "Child";//name of property with child arraylist this.gridGroupingControl1.TableDescriptor.Relations.Add(grd);