private void Done() { if (DialogResult == DialogResult.OK) { float defaultHeight = Units.Millimeters * 10; if (ReportWorkspace.Grid.GridUnits == PageUnits.Inches || ReportWorkspace.Grid.GridUnits == PageUnits.HundrethsOfInch) { defaultHeight = Units.Inches * 0.4f; } GroupHeaderBand initialGroup = null; DataBand data = null; int childIndex = -1; foreach (BandBase band in FPage.Bands) { if (band is GroupHeaderBand) { childIndex = band.ZOrder; initialGroup = band as GroupHeaderBand; data = (band as GroupHeaderBand).GroupDataBand; break; } else if (band is DataBand) { childIndex = band.ZOrder; data = band as DataBand; break; } } // report has no groups nor databands, create a databand if (childIndex == -1) { data = new DataBand(); data.Height = defaultHeight; childIndex = 0; } // connect groups to each other data.Parent = null; Base parent = null; for (int i = 0; i < lbGroups.Items.Count; i++) { GroupHeaderBand group = lbGroups.Items[i] as GroupHeaderBand; group.Parent = parent; group.Data = i < lbGroups.Items.Count - 1 ? null : data; parent = group; } // insert a group to the report page if (lbGroups.Items.Count > 0) { GroupHeaderBand firstGroup = lbGroups.Items[0] as GroupHeaderBand; FPage.Bands.Insert(childIndex, firstGroup); // create unique names if (String.IsNullOrEmpty(firstGroup.GroupDataBand.Name)) { firstGroup.GroupDataBand.CreateUniqueName(); } for (int i = 0; i < lbGroups.Items.Count; i++) { GroupHeaderBand group = lbGroups.Items[i] as GroupHeaderBand; if (String.IsNullOrEmpty(group.Name)) { group.Height = defaultHeight; group.CreateUniqueName(); // create text object with group name TextObject text = new TextObject(); text.Parent = group; text.CreateUniqueName(); text.Bounds = new RectangleF(new PointF(0, 0), text.GetPreferredSize()); text.Text = "[" + group.Condition + "]"; // create group footer group.GroupFooter = new GroupFooterBand(); group.GroupFooter.Height = defaultHeight; group.GroupFooter.CreateUniqueName(); } } } else { if (!String.IsNullOrEmpty(data.Name)) { FPage.Bands.Insert(childIndex, data); } } // delete initial group if it was deleted in the expert if (initialGroup != null && !lbGroups.Items.Contains(initialGroup)) { initialGroup.Dispose(); } } }