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

Engine + GridControl only

I''m trying to use a Grouping.Engine as the data for a GridControl running in virtual mode. The reason I''m not using GridGroupingControl is because I want the grouping rows to be multiple cells and I can''t figure out how to make GridGroupingControl do that. It''s working OK except that when I query DisplayElements.Count, I get elements for AddNewRecord and SummarySection, which I don''t want. If I were using a GridGroupingControl, I could just turn them off in the TableOptions. Is there anything similar in the engine? Or, to solve the problem a different way, can I get multiple columns in the grouping rows in the GridGroupingControl?

2 Replies

Administrator March 10, 2004 12:04 AM UTC

Hi Justin, to get rid of these section you need to derive from Engine class and override the CreateGroup and method. In your override you can then just add the sections you want, e.g: public class GroupingEngine : Engine { public override Group CreateGroup(Section parent) { return new GroupingGroup(parent); } } public class GroupingGroup : Group { public GroupingGroup(Section parent) : base(parent) { } protected override void OnInitializeSections(bool hasRecords, SortColumnDescriptorCollection fields) { this.Sections.Add(this.ParentTableDescriptor.CreateCaptionSection(this)); if (hasRecords) this.Sections.Add(this.ParentTableDescriptor.CreateRecordsDetails(this, fields)); else this.Sections.Add(this.ParentTableDescriptor.CreateGroupsDetails(this, fields)); this.Sections.Add(this.ParentTableDescriptor.CreateSummarySection(this)); } public override bool IsChildVisible(Element el) { if (el is CaptionSection) { return true; } else if (el is DetailsSection) { return this.IsExpanded; } else if (el is SummarySection) { return this.IsExpanded; } return true; } } but I think you should stick with grouping control. You can make the caption have multiple columns when you handle the QueryCoveredRange event of GridGroupingControl.TableControl.Model. void ModelQueryCoveredRange(object sender, GridQueryCoveredRangeEventArgs e) { GridTable thisTable = grid.Table; if (e.RowIndex < thisTable.DisplayElements.Count) { Element el = thisTable.DisplayElements[e.RowIndex]; switch (el.Kind) { case DisplayElementKind.Caption: e.Handled = true; break; } } } Setting e.Handled will prevent the GridTable class from setting a covered range for captions. Stefan

JK Justin Koh March 10, 2004 01:08 PM UTC

Thank you, Stefan. I''ll give it a shot.
Loader.
Live Chat Icon For mobile
Up arrow icon