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); }
// we must provide a MakeDoc implementation because // square brackets used in this sample grid's texts // are interpreted as expression parentheses otherwise. public C1.C1Preview.C1PrintDocument MakeDoc(C1FlexGridPrintInfo printInfo, C1.C1Preview.LongOperationEventHandler longOperation) { bool customBorders = _flex.DrawMode == DrawModeEnum.OwnerDraw; C1.C1Preview.C1PrintDocument doc = new C1.C1Preview.C1PrintDocument(); doc.TagOpenParen = "@@@["; doc.TagCloseParen = "@@@]"; C1.Win.C1FlexGrid.C1FlexGridPrinter printer = new C1.Win.C1FlexGrid.C1FlexGridPrinter(_flex); printer.LongOperation += longOperation; printer.PrintInfo = printInfo; // the best way to draw custom borders around the resulting table's cells is // to do it explicitly against the C1PrintDocument object model, hence this: printer.PrintInfo.PrintBorders = !customBorders; C1.C1Preview.RenderTable rtbl = printer.MakeGridTable(doc); if (customBorders) { // to draw custom borders, change them on the table returned: C1.C1Preview.LineDef lineBlack = new C1.C1Preview.LineDef("1pt", Color.Black); C1.C1Preview.LineDef lineGray = new C1.C1Preview.LineDef("1pt", Color.LightGray); C1.C1Preview.LineDef lineGreen = new C1.C1Preview.LineDef("2pt", Color.Green); // rtbl.Style.GridLines.Left = lineBlack; rtbl.Style.GridLines.Top = lineBlack; rtbl.Style.GridLines.Right = lineBlack; rtbl.Style.GridLines.Bottom = lineBlack; rtbl.Style.GridLines.Vert = lineGray; rtbl.Style.GridLines.Horz = lineGray; // "company" cell: rtbl.Cells[0, 1].Style.Borders.All = lineGreen; // "sales" group: rtbl.UserCellGroups.Add(new C1.C1Preview.UserCellGroup(new Rectangle(2, 0, 4, 2))); rtbl.UserCellGroups[0].Style.Borders.All = lineGreen; // "purchases" group: rtbl.UserCellGroups.Add(new C1.C1Preview.UserCellGroup(new Rectangle(6, 0, 4, 2))); rtbl.UserCellGroups[1].Style.Borders.All = lineGreen; } doc.Body.Children.Add(rtbl); doc.PageLayout.PageHeader = printer.MakePageHeader(doc); doc.PageLayout.PageFooter = printer.MakePageFooter(doc); return(doc); }
public void _flex_PrintCell(object sender, C1FlexGridPrintable2.PrintCellEventArgs e) { C1FlexGridPrintable2 flex = (C1FlexGridPrintable2)sender; // check if this is a row break if (flex.Rows[e.Row].UserData != null && flex.Rows[e.Row].UserData.ToString() == "*") { C1.C1Preview.RenderTable rtbl = e.TableCell.Table; int tblRow = e.TableCell.Row; // the marks are on LAST rows on page while PageBreakBehavior determines break BEFORE row, hence "+1": rtbl.Rows[tblRow + 1].PageBreakBehavior = C1.C1Preview.PageBreakBehaviorEnum.MustBreak; } // check if this is a column break if (flex.Cols[e.Col].UserData != null && flex.Cols[e.Col].UserData.ToString() == "*") { C1.C1Preview.RenderTable rtbl = e.TableCell.Table; int tblCol = e.TableCell.Col; // see comment above re "+1": rtbl.Cols[tblCol + 1].PageBreakBehavior = C1.C1Preview.PageBreakBehaviorEnum.MustBreak; } }
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); }