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.
Unfortunately, activation email could not send to your email. Please try again.

Adding a custom header row in GridComputingControl

Thread ID:

Created:

Updated:

Platform:

Replies:

19261 Sep 22,2004 06:00 AM Sep 23,2004 05:18 AM Windows Forms 3
loading
Tags: GridControl
Atif Iqbal Malik
Asked On September 22, 2004 06:00 AM

hi there, I am using a gridGroupingControl to bind with a DataTable in my form and am facing a problem. i am trying to add another header row in the grid, other than the already present column headers row, but am not being able to do so. I was wondering if anyone could provide any help in this matter. prompt reply will be appreciated. thanks, Atif.

Administrator [Syncfusion]
Replied On September 22, 2004 09:01 AM

Hi Atif, You can derive a class from GridChildTable and add your own custom rows there. To do this you also need to derive GridEngine and override the childtable factory method and register your custom engine. In QueryCellStyleInfo you can then specify contents for these rows. See attached example. Stefan GroupCustomers_4400.zip

Atif Iqbal Malik
Replied On September 22, 2004 11:31 PM

thanks Stefan. I am still unsure about where exactly to write code for adding header rows. if in (public class GroupingChildTable : GridChildTable) then which function/method? and which property of which object (ColumnDescriptor, TableDescriptor, etc.) do i have to access in order to add custom rows in the gridGroupingControl? i''ll appreciate if you could write i or 2 lines of code to clarify. thanks for your help. Atif

Administrator [Syncfusion]
Replied On September 23, 2004 05:18 AM

Hi Atif, they will be added in the OnInitializeSections override of GroupingChildTable. Look for the following lines in the sample: // GroupingEngineFactory provides a modified GridChildTable that adds an extra section GridEngineFactory.Factory = new GroupingEngineFactory(); this.groupingGrid1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(groupingGrid1_QueryCellStyleInfo); this.groupingGrid1.TableModel.QueryCoveredRange += new Syncfusion.Windows.Forms.Grid.GridQueryCoveredRangeEventHandler(TableModel_QueryCoveredRange); // QueryCoveredRange might or might not be of use for you ... private void TableModel_QueryCoveredRange(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCoveredRangeEventArgs e) { GridTableModel tm = sender as GridTableModel; Element el = tm.Table.DisplayElements[e.RowIndex]; if (el is ColumnHeaderRow) { GridTableCellStyleInfo style = tm[e.RowIndex, e.ColIndex]; //if (style.TableCellIdentity.Column.Name == "CustomerID" // || style.TableCellIdentity.Column.Name == "CompanyName") if (e.ColIndex >= 3 && e.ColIndex <= 4) e.Range = GridRangeInfo.Cells(e.RowIndex, 3, e.RowIndex, 4); e.Handled = true; } } // groupingGrid1_QueryCellStyleInfo lets you specify the text to be displayed in the additional headers private void groupingGrid1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) { e.Style.CellTipText = e.TableCellIdentity.Info; if (e.TableCellIdentity.DisplayElement is ExtraSection) { e.Style.CellValue = "Extra"; } } public class GroupingEngineFactory : GridEngineFactoryBase { public override GridEngine CreateEngine() { return new GroupingEngine(); } } public class GroupingEngine : GridEngine { public override ChildTable CreateChildTable(Element parent) { return new GroupingChildTable(parent); } } public class ExtraSection : EmptySection { public ExtraSection(Group parent) : base(parent) { } public override DisplayElementKind Kind { get { return DisplayElementKind.None; } } public override int GetElementCount() { return 1; } public override int GetVisibleCount() { return 1; } public override double GetYAmountCount() { return 40; } } public class GroupingChildTable : GridChildTable { public GroupingChildTable(Element parent) : base(parent) { } protected override void OnInitializeSections(bool hasRecords, SortColumnDescriptorCollection fields) { base.OnInitializeSections(hasRecords, fields); EndInit(); if (this.IsTopLevelGroup) { // Search for Detailssection for (int n = 0; n < Sections.Count; n++) { Section s = this.Sections[n]; if (s is DetailsSection) { // Insert before Details InvalidateCounter(); this.Sections.Insert(n, new ExtraSection(this)); break; } } } } public override bool IsChildVisible(Element el) { if (this.IsTopLevelGroup && el is ExtraSection) { return true; } else return base.IsChildVisible(el); } } Stefan

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;