$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
DataGridView WinForms Control
Print grid by using the GridView .NET component in C# Windows Forms application.
Home > WinForms UI Controls > User Manual > Grid Print Events in C#

Print Events and Customization for GridView

DataGridView .NET Component for Windows Forms allows the users easily to customize the grid print output for individual cell. This is accomplished by using the provided events, FormatPrintCell and PaintPrintCell. The GridView supports native print and the users of the application can directly pass the content of grid to a printer. By using the GridView .NET WinForms Control with friendly user dialogs, the UI designers can easily change the print settings, set watermark to the content of the grid and preview the print gird.

Create Formatting Print Grid Cell in C#

To create formatting cell in grid, we need to use the event, FormatPrintCell, included in the GridView C# class. This event works in the same way of any other formatting events of Kettic GridView and allows the developers to format the appearance of the cells that will be printed. The following is the C# code that shows how to customize the appearance of the header and the summary rows.

private void ketticGridView1_FormatPrintCell(object sender, FormatPrintCellEventArgs e)
{
if (e.Row is GridViewTableHeaderRowInformation)
{
e.PrintCell.DrawFill = true;
e.PrintCell.BackColor = Color.SkyBlue;
e.PrintCell.BorderColor = Color.Blue;
}
else if (e.Row is GridViewSummaryRowInformation)
{
e.PrintCell.DrawFill = true;
e.PrintCell.BackColor = Color.LightSalmon;
e.PrintCell.BorderColor = Color.Tomato;
}
}

How to Paint Print Grid Cell in C#

To paint print grid cell in C#.NET template projects, we need to use the event, PaintPrintCell, included in the GridView C# class. This event allows the developers to access the grid cell and paint the cells as their needs. The following is the C# code that shows how to paint a blue dot if the product quantity is larger than 50 and a purple dot when it is smaller.

private void ketticGridView1_PaintPrintCell(object sender, PaintPrintCellEventArgs e)
{
if (e.Row is GridViewDataRowInformation & e.Column.Name == "UnitsInStock")
{
int side = e.CellRect.Height - 10;
int x = e.CellRect.X + 5;
int y = e.CellRect.Y + 5;

Rectangle rect = new Rectangle(x, y, side, side);
Brush brush = default(Brush);

if (Convert.ToInt32(e.Row.Cells[e.Column.Name].Value) < 50)
{
brush = Brushes.Purple;
}
else
{
brush = Brushes.Blue;
}

e.Graphics.FillEllipse(brush, rect);
}
}
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls