// Handle C1FlexGridPrintable2.PrintCell event: // if we are printing the first cell containing an expanded child grid, // we use C1FlexGridPrinter to insert a RenderTable representing that // child grid into that cell. protected override void OnPrintCell(PrintCellEventArgs e) { base.OnPrintCell(e); if (!IsExpandedChildGridCell(e.Row, e.Col)) { return; } // get child grid occupying the current row: C1FlexGrid childGrid = (C1FlexGrid)Rows[e.Row - 1].UserData; System.Diagnostics.Debug.Assert(childGrid != null); C1FlexGridPrinter childPrinter = new C1FlexGridPrinter(childGrid); // use our own PrintInfo on the child: childPrinter.PrintInfo = this.Printer.PrintInfo; // make render object representing the child: C1.C1Preview.RenderObject childRO = childPrinter.MakeGridTable(e.TableCell.Table.Document); // span all columns to the right: e.TableCell.SpanCols = e.TableCell.Table.Cols.Count - 1; // allow the nested table to be split horizontally: e.TableCell.Table.Rows[e.TableCell.Row].SplitBehavior = C1.C1Preview.SplitBehaviorEnum.SplitIfNeeded; // set our cell's render object to the child grid: e.TableCell.RenderObject = childRO; }
// print the tree private void btnPrint_Click(object sender, System.EventArgs e) { #if not_C1FlexGridPrinter flex.PrintGrid("FlexTree", PrintGridFlags.ShowPreviewDialog); #else C1FlexGridPrinter printer = new C1FlexGridPrinter(flex); printer.PrintPreview(); #endif }
void _btnPrint_Click(object sender, System.EventArgs e) { // get rows/cols per page int rpp = 10; int cpp = 3; try { rpp = int.Parse(_rpp.Text); cpp = int.Parse(_cpp.Text); } catch {} // mark grid with row/column breaks C1FlexGrid[] flexArray = { _flex, _flex2 }; foreach (C1FlexGrid flex in flexArray) { for (int r = flex.Rows.Fixed; r < flex.Rows.Count; r++) { flex.Rows[r].UserData = (r % rpp == 0) ? "*" : null; } for (int c = flex.Cols.Fixed; c < flex.Cols.Count; c++) { flex.Cols[c].UserData = (c % cpp == 0) ? "*" : null; } } // print the grid using the specified page/column breaks #if not_needed_for_C1FlexGridPrinter PrintPreviewDialog dlg = new PrintPreviewDialog(); dlg.Document = new FlexPrintDocument("Two Grids", flexArray); dlg.Document.DefaultPageSettings.Landscape = true; dlg.ShowDialog(); #else // make C1PrintDocument containing both grids C1.C1Preview.C1PrintDocument doc = new C1.C1Preview.C1PrintDocument(); C1FlexGridPrinter prn1 = new C1FlexGridPrinter(_flex); C1FlexGridPrinter prn2 = new C1FlexGridPrinter(_flex2); // use landscape: doc.PageLayout.PageSettings.Landscape = true; // add grids to the document: doc.Body.Children.Add(prn1.MakeGridTable(doc)); // add a page break between the grids: doc.Body.Children.Add(new C1.C1Preview.RenderEmpty(C1.C1Preview.BreakEnum.Page)); doc.Body.Children.Add(prn2.MakeGridTable(doc)); C1.Win.C1Preview.C1PrintPreviewDialog pview = new C1.Win.C1Preview.C1PrintPreviewDialog(); pview.Document = doc; pview.ShowDialog(); #endif }
public C1.C1Preview.C1PrintDocument MakeDoc(C1FlexGridPrintInfo printInfo, C1.C1Preview.LongOperationEventHandler longOperation) { _callerLongOperation = longOperation; C1.C1Preview.C1PrintDocument doc = new C1.C1Preview.C1PrintDocument(); // there are many ways to skin a cat, or to render the four splits. // here, we use a master table with two rows and two columns, // rendering each grid in its own cell: C1.C1Preview.RenderTable table = new C1.C1Preview.RenderTable(); C1FlexGridPrinter prnTL = new C1FlexGridPrinter(_flexTL); prnTL.PrintInfo = printInfo; prnTL.LongOperation += new C1.C1Preview.LongOperationEventHandler(print_LongOperation); C1FlexGridPrinter prnTR = new C1FlexGridPrinter(_flexTR); prnTR.PrintInfo = printInfo; prnTR.LongOperation += new C1.C1Preview.LongOperationEventHandler(print_LongOperation); C1FlexGridPrinter prnBL = new C1FlexGridPrinter(_flexBL); prnBL.PrintInfo = printInfo; prnBL.LongOperation += new C1.C1Preview.LongOperationEventHandler(print_LongOperation); C1FlexGridPrinter prnBR = new C1FlexGridPrinter(_flexBR); prnBR.PrintInfo = printInfo; prnBR.LongOperation += new C1.C1Preview.LongOperationEventHandler(print_LongOperation); _currPrintedGrid = 0; table.Cells[0, 0].RenderObject = prnTL.MakeGridTable(doc); _currPrintedGrid = 1; table.Cells[0, 1].RenderObject = prnTR.MakeGridTable(doc); _currPrintedGrid = 2; table.Cells[1, 0].RenderObject = prnBL.MakeGridTable(doc); _currPrintedGrid = 3; table.Cells[1, 1].RenderObject = prnBR.MakeGridTable(doc); // by default, a table's width is set to 100% of its parent (here, page). // so we set it to auto, and enable horizontal page breaks: table.Width = "auto"; table.SplitHorzBehavior = C1.C1Preview.SplitBehaviorEnum.SplitIfNeeded; // by default, table rows and columns do not split; enable it here: table.Rows[0].SplitBehavior = C1.C1Preview.SplitBehaviorEnum.SplitIfNeeded; table.Rows[1].SplitBehavior = C1.C1Preview.SplitBehaviorEnum.SplitIfNeeded; table.Cols[0].SplitBehavior = C1.C1Preview.SplitBehaviorEnum.SplitIfNeeded; table.Cols[1].SplitBehavior = C1.C1Preview.SplitBehaviorEnum.SplitIfNeeded; // add thick blue gridlines between the splits: table.Style.GridLines.All = new C1.C1Preview.LineDef("2pt", Color.Blue); // the table with four splits is ready - add it to the documment: doc.Body.Children.Add(table); // use page headers from the top left grid: doc.PageLayout.PageHeader = prnTL.MakePageHeader(doc); doc.PageLayout.PageFooter = prnTL.MakePageFooter(doc); // done: return(doc); }
public C1.C1Preview.C1PrintDocument MakeDoc(C1FlexGridPrintInfo printInfo, C1.C1Preview.LongOperationEventHandler longOperation) { // select the grid to print: C1FlexGrid flex = C1FlexGridPrinterTest.SampleWrapper.FindGrid(this.tabControl1.SelectedTab); if (flex == null) { return(null); } C1.C1Preview.C1PrintDocument doc = new C1.C1Preview.C1PrintDocument(); C1FlexGridPrinter printer = new C1FlexGridPrinter(flex); printer.LongOperation += longOperation; printer.PrintInfo = printInfo; doc.PageLayout.PageHeader = printer.MakePageHeader(doc); doc.PageLayout.PageFooter = printer.MakePageFooter(doc); doc.Body.Children.Add(printer.MakeGridTable(doc)); return(doc); }
public C1.C1Preview.C1PrintDocument MakeDoc(C1FlexGridPrintInfo printInfo, C1.C1Preview.LongOperationEventHandler longOperation) { C1.C1Preview.C1PrintDocument doc = new C1.C1Preview.C1PrintDocument(); C1FlexGridPrinter prnCategories = new C1FlexGridPrinter(_flexCategories); prnCategories.LongOperation += longOperation; prnCategories.PrintInfo = printInfo; C1FlexGridPrinter prnProducts = new C1FlexGridPrinter(_flexProducts); prnProducts.LongOperation += longOperation; prnProducts.PrintInfo = printInfo; // make render tables representing the grids: C1.C1Preview.RenderTable tblCategories = prnCategories.MakeGridTable(doc); C1.C1Preview.RenderTable tblProducts = prnProducts.MakeGridTable(doc); // add a page break before the 2nd grid: tblProducts.BreakBefore = C1.C1Preview.BreakEnum.Page; // add grids to document: doc.Body.Children.Add(tblCategories); doc.Body.Children.Add(tblProducts); // done: return(doc); }
public FlexPdfCreator(C1FlexGridPrintable2 flex) { flex.PrintCell += new C1FlexGridPrintable2.PrintCellEventHandler(flex_PrintCell); _printer = new C1FlexGridPrinter(flex); }