The below class in a DataGridView that has a background image propert and a
backcolor2 and gradientmode. It draws the background and image in the
Paintbackgroun method.
HTH
Ciaran O'Donnell
http://wannabedeveloper.spaces.live.com/
public class DGV : DataGridView
{
private Image backgroundImage;
public Image BackgroundImage
{
get { return backgroundImage; }
set { backgroundImage = value; }
}
private Color backcolor2;
public Color BackgroundColor2
{
get { return backcolor2; }
set { backcolor2 = value; }
}
private System.Drawing.Drawing2D.LinearGradientMode gradientMode;
public System.Drawing.Drawing2D.LinearGradientMode GradientMode
{
get { return gradientMode; }
set { gradientMode = value; }
}
protected override void PaintBackground(Graphics graphics, Rectangle
clipBounds, Rectangle gridBounds)
{
graphics.FillRectangle(new
System.Drawing.Drawing2D.LinearGradientBrush(gridB ounds,
this.BackgroundColor, this.BackgroundColor2, gradientMode), gridBounds);
if (backgroundImage != null)
graphics.DrawImageUnscaled(backgroundImage, gridBounds);
}
}
"Diogo Alves - Software Developer" wrote:
Greetings,
I've been trying to put an image on the background of a datagrid,
I used the overriten property BackgroundImage, but it was useless (maybe I'm
missing something).
Could someone help me with this... I want to put a gradient on the
background of the datagrid... but can't find any way to do this....
Thanks in Advance