如何在visual studio中截取控件的屏幕截图?

时间:2018-05-27 11:49:12

标签: c# visual-studio

我使用以下几行来制作屏幕截图,但图像并不是特定于控制......它是在控制范围之外拍摄的。

Here is a screenshot

Rectangle rect = new Rectangle(this.tableLayoutPanel1.Location.X,
     this.tableLayoutPanel1.Location.Y, tableLayoutPanel1.Width, tableLayoutPanel1.Height);
Bitmap bmp = new Bitmap(rect.Width, rect.Height);
Graphics g = Graphics.FromImage(bmp);
g.CopyFromScreen(rect.Left, rect.Top, this.tableLayoutPanel1.Location.X, 
              this.tableLayoutPanel1.Location.Y, bmp.Size, CopyPixelOperation.SourceCopy);

0 个答案:

没有答案
相关问题