public int Add(ColumnBound ColumnBound) { if (ColumnBound.Left + ColumnBound.Width > _RightExtents) { _RightExtents = ColumnBound.Left + ColumnBound.Width; } ColumnBound.Page = _CurrentPage; return(base.Add(ColumnBound)); }
public int Add(ColumnBound ColumnBound) { if (ColumnBound.Left + ColumnBound.Width > _RightExtents) { _RightExtents = ColumnBound.Left + ColumnBound.Width; } ColumnBound.Page = _CurrentPage; return base.Add(ColumnBound); }
private void _GridPrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { if (_CurrentPageDown == 1 & _CurrentPageAcross == 1) { // _HeaderRectangle - The top 10% of the page _HeaderRectangle = e.MarginBounds; _HeaderRectangle.Height = Convert.ToInt32(e.MarginBounds.Height * _HeaderHeightPercent * 0.01); // _FooterRectangle - the bottom 10% of the page _FooterRectangle = e.MarginBounds; _FooterRectangle.Height = Convert.ToInt32(e.MarginBounds.Height * _FooterHeightPercent * 0.01); _FooterRectangle.Y += Convert.ToInt32(e.MarginBounds.Height * (1 - (0.01 * _FooterHeightPercent))); // _PageContentRectangle - The middle 80% of the page _PageContentRectangle = e.MarginBounds; _PageContentRectangle.Y += Convert.ToInt32(_HeaderRectangle.Height + e.MarginBounds.Height * (_InterSectionSpacingPercent * 0.01)); _PageContentRectangle.Height = Convert.ToInt32(e.MarginBounds.Height * 0.8); _Rowheight = e.Graphics.MeasureString("a", _PrintFont).Height; //\\ Create the _ColumnBounds array int nColumn = 0; double TotalWidth = 0; if (_DataGrid.DataSource == null) { //\\ Nothing in the grid to print return; } int ColumnCount = GridColumnCount(); //for (nColumn = 0; nColumn <= ColumnCount - 1; nColumn++) { // Rectangle rcLastCell = _DataGrid.Rows[0].Cells[nColumn].b; // if (rcLastCell.Width > 0) { // TotalWidth += rcLastCell.Width; // } //} TotalWidth = _DataGrid.Width; int TotalWidthOfAllPages = (e.MarginBounds.Width * PagesAcross); _ColumnBounds.Clear(); for (nColumn = 0; nColumn <= ColumnCount - 1; nColumn++) { //\\ Calculate the column start point ColumnBound NextColumn = new ColumnBound(); if (nColumn == 0) { NextColumn.Left = e.MarginBounds.Left; } else { NextColumn.Left = _ColumnBounds.RightExtents; } //\\ Set this column's width int rcCellWidth = _DataGrid.Rows[0].Cells[nColumn].Size.Width; if (rcCellWidth > 0) { rcCellWidth = rcCellWidth - 1; NextColumn.Width = (rcCellWidth / TotalWidth) * TotalWidthOfAllPages; if (NextColumn.Width > e.MarginBounds.Width) { NextColumn.Width = e.MarginBounds.Width; } } if (_ColumnBounds.RightExtents + NextColumn.Width > (e.MarginBounds.Left + e.MarginBounds.Width)) { _ColumnBounds.NextPage(); NextColumn.Left = e.MarginBounds.Left; } _ColumnBounds.Add(NextColumn); } if (_ColumnBounds.TotalPages > this.PagesAcross) { this.PagesAcross = _ColumnBounds.TotalPages; } } //\\ Print the document header PrintHeader(e); //\\ Print as many grid lines as can fit Int32 nextLine = default(Int32); PrintGridHeaderLine(e); int StartOfpage = _CurrentPrintGridLine; for (nextLine = _CurrentPrintGridLine; nextLine <= Min((_CurrentPrintGridLine + RowsPerPage(_PrintFont, e.Graphics)), ((System.Data.DataTable)_DataGrid.DataSource).DefaultView.Count); nextLine++) { PrintGridLine(e, nextLine); } _CurrentPrintGridLine = nextLine; //\\ Print the document footer PrintFooter(e); if (_CurrentPageAcross == PagesAcross) { _CurrentPageAcross = 1; _CurrentPageDown += 1; } else { _CurrentPageAcross += 1; _CurrentPrintGridLine = StartOfpage; } //\\ If there are more lines to print, set the HasMorePages property to true if (_CurrentPrintGridLine < GridRowCount()) { e.HasMorePages = true; } }