【问题标题】:How to save a screenshot of a control to the clipboard? [closed]如何将控件的屏幕截图保存到剪贴板? [关闭]
【发布时间】: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


    【解决方案1】:

    要将屏幕截图复制到整个控件的剪贴板,请使用以下函数:

        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);
        }
    

    【讨论】:

      【解决方案2】:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-09-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-08-04
        相关资源
        最近更新 更多