如何使用winforms
中的C#
将特定用户控件的屏幕快照保存到剪贴板?
要清楚,以下是我想要的:
public void SaveControlToClipboard(Control theControl){
// Gets a bitmap of the control and saves it to the clipboard
}
答案 0 :(得分:3)
要将屏幕截图复制到整个控件的剪贴板,请使用以下功能:
private void CopyControlToClipboard(Control theControl)
{
// Copy the whole control to a clicp board
Bitmap bm = new Bitmap(theControl.Width, theControl.Height);
theControl.DrawToBitmap(bm, new Rectangle(0, 0, theControl.Width, theControl.Height));
Clipboard.SetImage((Image)bm);
}
答案 1 :(得分:-1)
使用https://stackoverflow.com/a/29315808/6468720中的takeComponentScreenShot
并且比使用Clipboard.SetImage(Image),MSDN链接:https://docs.microsoft.com/ru-ru/dotnet/api/system.windows.forms.clipboard.setimage?view=netframework-4.8