Articles in this section
Category / Section

How to set the Watermark for the grid while printing in WinForms GridControl?

Watermark


There is no direct property to set the watermark in the WinForms GridControl. The WaterMark image can be added to print documents by using the PrintPage event. With this event, you can draw images on the print document by using graphics.


The following code example sets the background image for the Grid control and for drawing an image when printing a document.

//Sets the interior style for the Grid control.
this.gridControl1.BaseStylesMap.Standard.StyleInfo.Interior = new Syncfusion.Drawing.BrushInfo(System.Drawing.Color.Transparent);

//Sets the background image for the Grid control.
this.gridControl1.BackgroundImage = Image.FromFile(@"..\..\images.jpg");

//Sets the image Layout. 
this.gridControl1.BackgroundImageLayout = ImageLayout.Stretch;

void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
    // Draws image while printing.
    e.Graphics.DrawImage(this.gridControl1.BackgroundImage, e.PageBounds);
}
'Sets the interior style for the Grid control.
Me.gridControl1.BaseStylesMap.Standard.StyleInfo.Interior = New Syncfusion.Drawing.BrushInfo(System.Drawing.Color.Transparent)

‘Sets the background image for the Grid control.
Me.gridControl1.BackgroundImage = Image.FromFile("..\..\images.jpg")

'Sets the image Layout. 
Me.gridControl1.BackgroundImageLayout = ImageLayout.Stretch

void pd_PrintPage(Object sender, System.Drawing.Printing.PrintPageEventArgs e)
 ' Draws the image while printing.
 e.Graphics.DrawImage(Me.gridControl1.BackgroundImage, e.PageBounds)
End Sub

The screenshot below displays the watermark text in the Grid

 

Watermark in the grid


   Figure
1: Watermark in the Grid


Samples:

C#: WaterMarkImage_CS

VB: WaterMarkImage_VB

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied