【发布时间】:2019-08-02 20:58:18
【问题描述】:
如何在C# 中使用winforms 将特定用户控件的屏幕截图保存到剪贴板?
明确以下是我想要的:
public void SaveControlToClipboard(Control theControl){
// Gets a bitmap of the control and saves it to the clipboard
}
【问题讨论】:
如何在C# 中使用winforms 将特定用户控件的屏幕截图保存到剪贴板?
明确以下是我想要的:
public void SaveControlToClipboard(Control theControl){
// Gets a bitmap of the control and saves it to the clipboard
}
【问题讨论】:
要将屏幕截图复制到整个控件的剪贴板,请使用以下函数:
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);
}
【讨论】:
使用 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
【讨论】: