public partial class UserDataGridView : DataGridView
{
private Image m_Image;
public UserDataGridView()
{
InitializeComponent();
//this.m_Image = Image.FromFile("C:\\BG.jpg");
//this.m_Image = Resources.网格背景;
}
///<summary>重写PaintBackground</summary>
protected override void PaintBackground(Graphics graphics, Rectangle clipBounds, Rectangle gridBounds)
{
base.PaintBackground(graphics, clipBounds, gridBounds);
graphics.DrawImage(this.m_Image, gridBounds);
}
/// <summary>设置背景图片</summary>
public Image BackImage
{
get
{
return this.m_Image;
}
set
{
this.m_Image = value;
base.Refresh(); // 重新加载
}
}