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
close icon

Spanning/CoveredCells for Grouped Columns

I have a grid which is grouped by 2 adjacent cols Country and then Customer Name. I''d like the caption to the right of the +/-) to cover both the countyr and customer name coliumns for each row Is this possible? Thanks Jason

4 Replies

AD Administrator Syncfusion Team June 11, 2004 02:47 PM UTC

Do I understand you correct that you do just want to have a different caption for the customer name and simply display there both the country and the customer name in that caption? In that case, you could handle the QueryCellStyleInfo event. private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if( e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell && e.TableCellIdentity.GroupedColumn != null && e.TableCellIdentity.GroupedColumn.Name == "Customer" ) { GridCaptionRow captionRow = e.TableCellIdentity.DisplayElement as GridCaptionRow; GridCaptionSection captionSection = captionRow.ParentSection as GridCaptionSection; e.Style.Text = "Country: " + captionRow.ParentGroup.ParentGroup.Category + "Customer: " + captionRow.ParentGroup.Category; } } But let me know if I misunderstood. Stefan

AD Administrator Syncfusion Team June 14, 2004 08:17 AM UTC

Thanks for you reply. I''ve attached a sample application (visual studio 2003). I''m grouping my grid by "Sector Major", "Sector" and "Currency", with other columns displayed, Asset, Selected, Position, PositionAdjusted The caption for all groups (to the right of the +/- button) only fits into the width of the first display column (Sector Major). I''d like those group captions to extend (or Cover) all the way across the 3 grouped cells rather than be wrapped to the width of the first. I could then clear the display text for the SectorMajor, Sector and Currnecy in each row as that is duplicated using the QueryCellStyleInfo event Thanks in advance gridgrouping03_6576.zip

AD Administrator Syncfusion Team June 14, 2004 08:30 AM UTC

I''ve attached a "before" and "after" to show waht I''m trying to achieve thanks again Jason gridgrouping screens_1298.zip

AD Administrator Syncfusion Team June 16, 2004 12:28 AM UTC

Hi Jason, attached find modified versions for your code: Form1_594.zip These are the changed methods: private void checkBox7_CheckedChanged(object sender, System.EventArgs e) { gridGroupingControl3.TableModel.CoveredRanges.Clear(); if (checkBox7.Checked) { gridGroupingControl3.TableDescriptor.Columns[POSITION].HeaderText = "2219 ADG AHIT"; this.gridGroupingControl3.TableModel.QueryCoveredRange += new Syncfusion.Windows.Forms.Grid.GridQueryCoveredRangeEventHandler(TableModel_QueryCoveredRange); } else { this.gridGroupingControl3.TableModel.QueryCoveredRange -= new Syncfusion.Windows.Forms.Grid.GridQueryCoveredRangeEventHandler(TableModel_QueryCoveredRange); } gridGroupingControl3.Refresh(); } 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 CaptionRow) { GridTableCellStyleInfo style = tm[e.RowIndex, e.ColIndex]; int maxCaptionColCount = Math.Max(tm.Table.TableDescriptor.GetColumnIndentCount(), tm.Table.TableDescriptor.GetColCount()-1); int startCol = el.GroupLevel+1; maxCaptionColCount = Math.Min(5+1, maxCaptionColCount); IGridGroupOptionsSource g = el.ParentGroup as IGridGroupOptionsSource; if (g != null && !g.GroupOptions.ShowCaptionPlusMinus) { startCol--; } int d = (el.ParentTable.RelatedTables.Count > 0) ? 1 : 0; if (!((GridTable) el.ParentTable).TableOptions.ShowRecordPlusMinus) d = 0; if (e.ColIndex >= startCol && e.ColIndex <= maxCaptionColCount) { e.Range = GridRangeInfo.Cells(e.RowIndex, startCol, e.RowIndex, maxCaptionColCount); e.Handled = true; } } } Stefan

Live Chat Icon For mobile
Up arrow icon