How to get the screenshot of the form

后端 未结 8 918
悲&欢浪女
悲&欢浪女 2020-12-02 23:14

Any method to output the screenshot of an active form?

8条回答
  •  盖世英雄少女心
    2020-12-03 00:01

    Use the Control.DrawToBitmap() method. For example:

        private void timer1_Tick(object sender, EventArgs e) {
            var frm = Form.ActiveForm;
            using (var bmp = new Bitmap(frm.Width, frm.Height)) {
                frm.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
                bmp.Save(@"c:\temp\screenshot.png");
            }
        }
    

提交回复
热议问题