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

C# 如何在windows窗体C中打印可滚动面板#,c#,winforms,screenshot,C#,Winforms,Screenshot,我有一个自定义控件,它有一个可滚动的面板,整个内容在屏幕上不可见。(需要滚动才能看到所有内容) 用户希望准确地打印面板在屏幕上的外观,但用户希望整个面板在屏幕上不滚动就看不见 如何在多个页面中捕获和打印整个面板 非常感谢您的帮助。这可能会对您有所帮助 pnlReport.AutoScrollPosition = new Point(0, 0); public void DrawControl(Control control, Bitmap bitmap) {

我有一个自定义控件,它有一个可滚动的面板,整个内容在屏幕上不可见。(需要滚动才能看到所有内容)

用户希望准确地打印面板在屏幕上的外观,但用户希望整个面板在屏幕上不滚动就看不见

如何在多个页面中捕获和打印整个面板

非常感谢您的帮助。

这可能会对您有所帮助

    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();
    }
这可能对你有帮助

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

你能提供它的外观和代码的截图吗?更多信息将有助于确定您正试图记录的内容,您是否可以提供一个屏幕截图,显示它的外观和代码?更多的信息将有助于确定您正试图做什么