How to get a screen capture of a .Net WinForms control programmatically?

前端 未结 7 2041
抹茶落季
抹茶落季 2020-12-13 09:30

How do you programmatically obtain a picture of a .Net control?

7条回答
  •  天涯浪人
    2020-12-13 09:50

    This is how to do it for an entire Form, not just the Client area (which doesn't have the title bar and other dressing)

            Rectangle r = this.Bounds;
            r.Offset(-r.X,-r.Y);
            Bitmap bitmap = new Bitmap(r.Width,r.Height);
            this.DrawToBitmap(bitmap, r);
            Clipboard.SetImage(bitmap);
    

提交回复
热议问题