vs2005里面给控件提供了DrawToBitmap函数
例如:
//
保存窗体到图片
Bitmap formBitmap
=
new
Bitmap(
this
.Width,
this
.Height);
this
.DrawToBitmap(formBitmap,
new
Rectangle(
0
,
0
,
this
.Width,
this
.Height)); formBitmap.Save(
@"
d:\form.bmp
"
, ImageFormat.Bmp);
//
保存控件DataGridView到图片
Bitmap controlBitmap
=
new
Bitmap(
this
.dataGridView1.Width,
this
.dataGridView1.Height);
this
.dataGridView1.DrawToBitmap(controlBitmap,
new
Rectangle(
0
,
0
,
this
.dataGridView1.Width,
this
.dataGridView1.Height)); controlBitmap.Save(
@"
d:\control.bmp
"
, ImageFormat.Bmp);
转载于:https://www.cnblogs.com/tuyile006/archive/2008/03/18/1111576.html