private void button1_Click( object sender, EventArgs e)
{
// Create a bitmap for save
Bitmap bmp = new Bitmap(dataGridView1.Width,
dataGridView1.Width,
PixelFormat.Format32bppPArgb);
// Create a graphic for drawing from bmp
Point point = new Point(dataGridView1.Left,
dataGridView1.Top);
Graphics screenG = Graphics.FromImage(bmp);
screenG.CopyFromScreen(PointToScreen(point),
new Point(0, 0),
dataGridView1.Size,
CopyPixelOperation.SourceCopy);
bmp.Save( "abc.bmp" ); // save the screenshot
}
|