C# 如何在VisualStudio中拍摄控件的屏幕截图?

C# 如何在VisualStudio中拍摄控件的屏幕截图?,c#,visual-studio,C#,Visual Studio,我用以下几行来做截图,但图像不是特定于控制的…它是在控制范围之外拍摄的 ? 仅供参考如果您想探索由类型公开的方法,可以键入变量名称,后跟句点,Visual Studio将列出公共方法、属性和字段。我的代码搞错了。这是一个工作版本:Rectangle=tableLayoutPanel1.RectangleToScreen(tableLayoutPanel1.ClientRectangle);//或tableLayoutPanel1.Bounds位图bmp=新位图(rect.Width,rect.

我用以下几行来做截图,但图像不是特定于控制的…它是在控制范围之外拍摄的


? 仅供参考如果您想探索由类型公开的方法,可以键入变量名称,后跟句点
,Visual Studio将列出公共方法、属性和字段。我的代码搞错了。这是一个工作版本:
Rectangle=tableLayoutPanel1.RectangleToScreen(tableLayoutPanel1.ClientRectangle);//或tableLayoutPanel1.Bounds位图bmp=新位图(rect.Width,rect.Height);使用(Graphics g=Graphics.FromImage(bmp))g.CopyFromScreen(rect.Location,Point.Empty,rect.Size)绘制到位图将不保存,因为我想保存富文本框,但它们没有使用该功能保存的属性我编写了您的代码,但存在相同的问题…将图像从表中取出…您是指我的代码吗?在这里很好用。请显示您的当前版本和当前结果!
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);