简体   繁体   English

如何在Windows窗体C#中打印可滚动面板

[英]How to print scroll-able panel in windows form C#

i have custom control which has one scrollable panel, which entire content is not visible on screen.(Need to scroll to see all content) 我有一个具有一个可滚动面板的自定义控件,整个内容在屏幕上不可见。(需要滚动以查看所有内容)

User wants to print the panel exactly how it looks on screen but user wants entire panel which is not visible on screen without scrolling. 用户想要精确地打印面板在屏幕上的外观,但是用户希望整个面板在不滚动的情况下在屏幕上不可见。

How to capture and print whole panel in multiple pages? 如何在多页中捕获和打印整个面板?

Any help is appreciated. 任何帮助表示赞赏。

this may help you. 这可能对您有帮助。

    pnlReport.AutoScrollPosition = new Point(0, 0);

    public void DrawControl(Control control, Bitmap bitmap)
    {
        control.DrawToBitmap(bitmap, control.Bounds);
        foreach (Control childControl in control.Controls)
        {
            DrawControl(childControl, bitmap);
        }
    }


    public void SaveBitmap(string filename)
    {
        var size = myControl.PreferredSize;
        var height = size.Height;
        Bitmap bmp = new Bitmap(this.myControl.Width, height);

        this.myControl.DrawToBitmap(bmp, new Rectangle(0, 0, this.myControl.Width, height));
        foreach (Control control in myControl.Controls)
        {
            DrawControl(control, bmp);
        }

        bmp.Save(filename, ImageFormat.Jpeg);
        bmp.Dispose();
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM