Source: http://www.codeproject.com/KB/grid/Datagridview_BackImage.aspx
VB. NET
Imports System. componentmodel
Imports System. Drawing
Public Class Userdatagridview
Inherits Windows. Forms. datagridview
Private M_image As Image
Public Sub New ()
' Me. m_image = drawing. image. fromfile ("C: \ bg.jpg ")
End sub
Protected Overrides Sub Paintbackground ( Byval Graphics As Graphics, Byval Clipbounds As Rectangle, Byval Gridbounds As Rectangle)
Mybase . Paintbackground (graphics, clipbounds, gridbounds)
Graphics. drawimage ( Me . M_image, gridbounds)
End sub
' Add image attributes
Public Property Backimage () As Drawing. Image
Get
Return Me . M_image
End Get
Set ( Byval Value As Drawing. Image)
Me . M_image = Value
Mybase . Refresh ()
End Set
End Property
End Class
C #
Using System;
Using System. Collections. Generic;
Using System. componentmodel;
Using System. Data;
Using System. drawing;
Using System. LINQ;
Using System. text;
Using System. Windows. forms;
Namespace Userdatagridview
{
Public Partial Class Userdatagridview: datagridview
{
Private Image m_image;
Public Userdatagridview ()
{
Initializecomponent ();
// This. m_image = image. fromfile ("C: \ bg.jpg ");
}
/// <Summary> Override paintbackground </Summary>
Protected Override Void Paintbackground (Graphics graphics, rectangle clipbounds, rectangle gridbounds)
{
Base . Paintbackground (graphics, clipbounds, gridbounds );
Graphics. drawimage ( This . M_image, gridbounds );
}
/// <Summary> Set background image </Summary>
Public Image backimage
{
Get
{
Return This . M_image;
}
Set
{
This . M_image = Value;
Base . Refresh (); // Reload
}
}
}
}