public ParentItem(string name, string sname, string cname, ChildList dt) { this.name = name; this.supplier_name = sname; this.company_name = cname; this.child = dt; }
/// <summary> /// Sets the ArrayList datasource to the Grid. /// </summary> private void SetArrayListData() { #region Adding data to the ArrayList ChildList cl1 = new ChildList(); cl1.Add(new ArrayListData(1, "Condiments", "Sweets", "")); ChildList cl2 = new ChildList(); cl2.Add(new ArrayListData(2, "Confections", "Deserts", "")); cl2.Add(new ArrayListData(2, "Confections", "Candies", "")); ChildList cl3 = new ChildList(); cl3.Add(new ArrayListData(3, "Grains/Cereals", "Breads", "")); cl3.Add(new ArrayListData(3, "Grains/Cereals", "Pasta", "")); cl3.Add(new ArrayListData(3, "Grains/Cereals", "Cereal", "")); ChildList cl4 = new ChildList(); cl4.Add(new ArrayListData(4, "Meat/Poultry", "Prepared meats", "")); ChildList cl5 = new ChildList(); cl5.Add(new ArrayListData(5, "Produce", "Dried fruit", "")); cl5.Add(new ArrayListData(5, "Produce", "Bean curd", "")); ChildList cl6 = new ChildList(); cl6.Add(new ArrayListData(6, "Seafood", "Fish", "")); cl6.Add(new ArrayListData(6, "Seafood", "Seeweed", "")); 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)); 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)); 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)); 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)); 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)); #endregion this.gridGroupingControl1.AllowProportionalColumnSizing = true; //Assigning DataSource to grid this.gridGroupingControl1.DataSource = null; this.gridGroupingControl1.DataSource = al; this.gridGroupingControl1.Engine.SetSourceList(al); //A relationship between tables established by the gridrelation descriptor's UniformChildList. GridRelationDescriptor grd = new GridRelationDescriptor(); grd.RelationKind = RelationKind.UniformChildList; grd.MappingName = "Child";//name of property with child arraylist this.gridGroupingControl1.Engine.SourceListSet.Clear(); this.gridGroupingControl1.TableDescriptor.Columns.Clear(); //Adding columns to the Grid table descriptor. this.gridGroupingControl1.TableDescriptor.Columns.Add("CategoryName"); this.gridGroupingControl1.TableDescriptor.Columns.Add("SupplierName"); this.gridGroupingControl1.TableDescriptor.Columns.Add("CompanyName"); this.gridGroupingControl1.TableDescriptor.Relations.Add(grd); //Setting Column header text. this.gridGroupingControl1.TableDescriptor.Columns["CategoryName"].HeaderText = "Category Name"; this.gridGroupingControl1.TableDescriptor.Columns["SupplierName"].HeaderText = "Supplier Name"; this.gridGroupingControl1.TableDescriptor.Columns["CompanyName"].HeaderText = "Company Name"; //Setting AllowNew and ReadOnly property value. foreach (GridTableDescriptor td in this.gridGroupingControl1.Engine.EnumerateTableDescriptor()) { if (td.ParentTableDescriptor != null) { td.Columns["CategoryName"].HeaderText = "Category Name"; td.Columns["CategoryID"].HeaderText = "Category ID"; td.Columns["OtherInfo"].HeaderText = "Other Info"; } } this.gridGroupingControl1.GetTable("Child").DefaultRecordRowHeight = 22; }