On the other hand if you want to customize the result by using code, you have a bunch of options available. On the higher level you can customize the RadPrintDocument which offers options for headers, footers, paper sizes, margins and the lot. But what we are here for is to dig deeper into the RadGridView print settings.
For this example, let’s take a look at the Employees table from the Northwind database. The first thing to note is that you can print all types of view definitions and you do not have to worry about it, the RadGridView will handle it for you. To get going, we first have to decide how the RadGridView will be laid out on the printed sheet of paper. Let`s set up our grid to be printed in the center without resizing it:
.radGridView1.PrintStyle.FitWidthMode = PrintFitWidthMode.NoFitCentered;
, 9, FontStyle.Bold);
.radGridView1.PrintStyle.HeaderCellBackColor = Color.LightBlue;
, 10, FontStyle.Regular);
.radGridView1.PrintStyle.GroupRowBackColor = Color.PaleGoldenrod;
sender, PrintCellFormattingEventArgs e)
GridViewDataRowInfo && e.Column.Name ==
DateTime date = (DateTime)e.Row.Cells[e.Column.Name].Value;
(date.Year + 20 <= DateTime.Now.Year)
e.PrintCell.BackColor = Color.LightGray;
sender, PrintCellPaintEventArgs e)
GridViewDataRowInfo && e. Column.Name ==
SmoothingMode smoothingMode = e.Graphics.SmoothingMode;
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
diameter = e.CellRect.Height / 2;
circleRectX = e.CellRect.X + e.CellRect.Width - diameter - (diameter / 2);
circleRectY = e.CellRect.Y + diameter / 2;
Rectangle circleRect =
Rectangle(circleRectX, circleRectY, diameter, diameter);
(date.DayOfYear >= DateTime.Now.DayOfYear)
e.Graphics.SmoothingMode = smoothingMode;
For more information about the printing support and its tweaks, you can check our brand new video Getting Started with Printing for RadGridView.
Let the printing begin!
Nikolay Diyanov Diyanov is the Product Manager of the Native Mobile UI division at Progress. Delivering outstanding solutions that make developers' lives easier is his passion and the biggest reward in his work. In his spare time, Nikolay enjoys travelling around the world, hiking, sun-bathing and kite-surfing.
Find him on Twitter @n_diyanov or on LinkedIn.