支持DataGridView 长截图 ,无视滚动条
public void SaveToImage(DataGridView DataGridView1) {
int height;
DataGridView1.Visible = false;
DataGridView1.Dock = DockStyle.None;
height = DataGridView1.ColumnHeadersHeight + DataGridView1.Rows.GetRowsHeight(DataGridViewElementStates.Visible) + 1;
DataGridView1.Width =400;
DataGridView1.Height = DataGridView1.ColumnHeadersHeight + (height) + 10;
Bitmap a = new Bitmap(DataGridView1.Bounds.Width, DataGridView1.Bounds.Height);
dataGridView1.DrawToBitmap(a, DataGridView1.Bounds);
DataGridView1.Dock = DockStyle.Fill;
DataGridView1.Visible = true;
Clipboard.SetImage(a);
}