DataGridView Background

G

Guest

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
 
G

Guest

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(gridBounds,
this.BackgroundColor, this.BackgroundColor2, gradientMode), gridBounds);
if (backgroundImage != null)
graphics.DrawImageUnscaled(backgroundImage, gridBounds);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top