Thank you for writing.
and I have added a vote for it on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link -
Currently, the possible solution that I can suggest is to use the following code snippet:
public
class
CustomGridPrintStyle : GridPrintStyle
{
protected
override
BaseGridPrintRenderer InitializePrintRenderer(RadGridView grid)
{
if
(
this
.PrintRenderer !=
null
)
{
this
.PrintRenderer.PrintCellPaint -= renderer_PrintCellPaint;
this
.PrintRenderer.PrintCellFormatting -= renderer_PrintCellFormatting;
this
.PrintRenderer.ChildViewPrinting -= renderer_ChildViewPrinting;
}
BaseGridPrintRenderer renderer =
null
;
if
(grid.ViewDefinition.GetType() ==
typeof
(ColumnGroupsViewDefinition))
{
if
(!(renderer
is
ColumnGroupsViewDefinitionPrintRenderer))
{
renderer =
new
CustomColumnGroupsViewDefinitionPrintRenderer(grid);
}
}
else
if
(grid.ViewDefinition.GetType() ==
typeof
(HtmlViewDefinition))
{
if
(!(renderer
is
HtmlViewDefinitionPrintRenderer))
{
renderer =
new
HtmlViewDefinitionPrintRenderer(grid);
}
}
else
{
if
(!(renderer
is
TableViewDefinitionPrintRenderer))
{
renderer =
new
TableViewDefinitionPrintRenderer(grid);
}
}
renderer.ChildViewPrinting += renderer_ChildViewPrinting;
renderer.PrintCellFormatting += renderer_PrintCellFormatting;
renderer.PrintCellPaint += renderer_PrintCellPaint;
return
renderer;
}
private
void
renderer_PrintCellPaint(
object
sender, PrintCellPaintEventArgs e)
{
this
.OnPrintCellPaint(sender, e);
}
private
void
renderer_PrintCellFormatting(
object
sender, PrintCellFormattingEventArgs e)
{
this
.OnPrintCellFormatting(sender, e);
}
private
void
renderer_ChildViewPrinting(
object
sender, ChildViewPrintingEventArgs e)
{
this
.OnChildViewPrinting(sender, e);
}
}
public
class
CustomColumnGroupsViewDefinitionPrintRenderer : ColumnGroupsViewDefinitionPrintRenderer
{
public
CustomColumnGroupsViewDefinitionPrintRenderer(RadGridView grid) :
base
(grid)
{
}
protected
override
void
PrintRow(GridViewRowInfo row, ColumnGroupRowLayout rowLayout, GridPrintSettings settings,
int
currentX,
int
currentY, Graphics graphics)
{
float
scrollableColumnsOffset = 0f;
float
rightPinnedColumnsOffset = 0f;
foreach
(GridViewColumn col
in
rowLayout.RenderColumns)
{
if
(col
is
GridViewRowHeaderColumn || col
is
GridViewIndentColumn)
{
continue
;
}
float
height = rowLayout.GetRowHeight(row);
RectangleF cellBounds = rowLayout.GetCorrectedColumnBounds(row, col,
this
.GridView.RightToLeft == RightToLeft.Yes,
new
RectangleF(0f, 0f, rowLayout.DesiredSize.Width, height));
if
(cellBounds == RectangleF.Empty)
{
continue
;
}
if
(col.PinPosition == PinnedColumnPosition.Left)
{
if
(scrollableColumnsOffset < cellBounds.Right + rowLayout.Owner.CellSpacing)
{
scrollableColumnsOffset = cellBounds.Right + rowLayout.Owner.CellSpacing;
rightPinnedColumnsOffset = scrollableColumnsOffset;
}
}
else
if
(col.PinPosition == PinnedColumnPosition.None)
{
if
(rightPinnedColumnsOffset < scrollableColumnsOffset + cellBounds.Right + rowLayout.Owner.CellSpacing)
{
rightPinnedColumnsOffset = scrollableColumnsOffset + cellBounds.Right + rowLayout.Owner.CellSpacing;
}
cellBounds.X += scrollableColumnsOffset;
}
else
{
cellBounds.X += rightPinnedColumnsOffset;
}
cellBounds.Offset(currentX, currentY);
GridViewCellInfo cell;
CellPrintElement printCell;
if
(row
is
GridViewTableHeaderRowInfo)
{
cell =
this
.GridView.MasterView.TableHeaderRow.Cells[col.Name];
printCell =
this
.CreateHeaderCellPrintElement(col);
if
(printCell.Font != settings.HeaderCellFont)
{
if
(settings.HeaderCellFont !=
null
)
{
printCell.Font = settings.HeaderCellFont;
}
else
{
settings.HeaderCellFont = printCell.Font;
}
}
}
else
if
(row
is
GridViewSummaryRowInfo)
{
GridViewSummaryRowInfo rowInfo = row
as
GridViewSummaryRowInfo;
cell = rowInfo.Cells[col.Name];
if
(cell ==
null
)
{
continue
;
}
printCell =
this
.CreateSummaryCellPrintElement(cell);
if
(printCell.Font != settings.SummaryCellFont)
{
if
(settings.SummaryCellFont !=
null
)
{
printCell.Font = settings.SummaryCellFont;
}
else
{
settings.SummaryCellFont = printCell.Font;
}
}
}
else
{
cell = row.Cells[col.Name];
if
(cell ==
null
)
{
continue
;
}
if
(col
is
GridViewImageColumn)
{
printCell =
this
.CreateImageCellPrintElement(cell);
}
else
{
printCell =
this
.CreateDataCellPrintElement(cell);
if
(printCell.Font != settings.CellFont)
{
if
(settings.CellFont !=
null
)
{
printCell.Font = settings.CellFont;
}
else
{
settings.CellFont = printCell.Font;
}
}
}
}
printCell.TextPadding =
this
.GridView.PrintStyle.CellPadding;
printCell.RightToLeft =
this
.GridView.RightToLeft == RightToLeft.Yes;
Rectangle rect =
new
Rectangle((
int
)cellBounds.X, (
int
)cellBounds.Y, (
int
)cellBounds.Width, (
int
)cellBounds.Height);
PrintCellFormattingEventArgs formattEventArgs =
new
PrintCellFormattingEventArgs(row, col, printCell);
this
.OnPrintCellFormatting(formattEventArgs);
formattEventArgs.PrintCell.Paint(graphics, rect);
PrintCellPaintEventArgs paintEventArgs =
new
PrintCellPaintEventArgs(graphics, row, col, rect);
this
.OnPrintCellPaint(paintEventArgs);
}
}
}
private
void
radButton1_Click(
object
sender, EventArgs e)
{
CustomGridPrintStyle style =
new
CustomGridPrintStyle();
this
.radGridView1.PrintStyle = style;
RadPrintDocument printDoc =
new
RadPrintDocument();
printDoc.Landscape =
true
;
printDoc.RightHeader =
"Right Header"
;
printDoc.HeaderHeight = 100;
printDoc.AssociatedObject =
this
.radGridView1;
RadPrintPreviewDialog dialog =
new
RadPrintPreviewDialog(printDoc);
dialog.Size =
new
System.Drawing.Size(Screen.PrimaryScreen.Bounds.Width - 200, Screen.PrimaryScreen.Bounds.Height - 200);
dialog.SetZoom(0.80);
dialog.ShowDialog();
}
I hope this information helps. Should you have further questions I would be glad to help.