private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) { GridGroupingControl groupingControl = (GridGroupingControl)sender; Element el = e.TableCellIdentity.DisplayElement; e.Style.CellTipText = el.GetType().Name + (el.ParentElement != null ? " (Parent: " + el.ParentElement.GetType().Name + ")" : ""); if (el is ExtraSection) { if (e.Style.TableCellIdentity.ColIndex == 0) { // Row Header e.Style.CellType = ((GridTableDescriptor)el.ParentTableDescriptor).Appearance.RecordRowHeaderCell.CellType; if (el == el.ParentTable.CurrentElement) { e.Style.Text = "#"; } } else if (e.Style.TableCellIdentity.ColIndex <= el.GroupLevel) { // Group Indent e.Style.BackColor = Color.FromArgb(218, 229, 245); } else if (e.Style.TableCellIdentity.ColIndex <= extraSectionCoverCols + el.ParentTableDescriptor.GroupedColumns.Count) { // Covered area (see TableModel_QueryCoveredRange above) e.Style.BackColor = Color.FromArgb(192, 201, 219); e.Style.CellValue = "ExtraSection (" + el.ParentGroup.Name + ")"; } else if (e.Style.TableCellIdentity.ColIndex > 3) { e.Style.BackColor = Color.FromArgb(252, 172, 38); // you can get the column as follows: GridTable table = (GridTable)el.ParentTable; GridTableDescriptor td = e.TableCellIdentity.Table.TableDescriptor; GridColumnDescriptor column = td.RecordRowColumns[0, e.Style.TableCellIdentity.ColIndex - el.ParentTableDescriptor.GroupedColumns.Count - 1]; e.Style.CellValue = column.Name; // Using that column you could try and identify the summary that should be displayed in this cell. if (column.MappingName == "Freight") { // Calling this method to demonstrate different alternatives to get to the summary text e.Style.Text = GetSummaryText(el.ParentGroup, "SummaryRow 1", "FreightAverage"); // Easier is to simple call built-in routine: e.Style.Text = GridEngine.GetSummaryText(el.ParentGroup, "SummaryRow 1", "FreightAverage"); } } } }
private void Gc1_SourceListListChangedCompleted(object sender, TableListChangedEventArgs e) { var r = this.gc1.TableModel.RowCount; var p = this.gc1.TableModel.Rows.Model.RowCount; GridSummaryRow rec = this.gc1.Table.DisplayElements[r] as GridSummaryRow; GridRecordRow row = this.gc1.Table.DisplayElements[r] as GridRecordRow; if (row is GridRecordRow) { MessageBox.Show("row"); } if (rec is GridSummaryRow) { foreach (var scd in rec.SummaryRowDescriptor.SummaryColumns) { if (scd.Name == "Machine Hours Remaining") { txtMachine.Text = GridEngine.GetSummaryText(rec.ParentGroup, scd); } else if (scd.Name == "Weld Hours Remaining") { txtWeld.Text = GridEngine.GetSummaryText(rec.ParentGroup, scd); } else if (scd.Name == "Build Hours Remaining") { txtBuild.Text = GridEngine.GetSummaryText(rec.ParentGroup, scd); } else if (scd.Name == "Tracker Hours Remaining") { txtTrackers.Text = GridEngine.GetSummaryText(rec.ParentGroup, scd); } else if (scd.Name == "Design Hours Remaining") { txtDesign.Text = GridEngine.GetSummaryText(rec.ParentGroup, scd); } } } }