簡體   English   中英

如何在Windows窗體C#中打印可滾動面板

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

我有一個具有一個可滾動面板的自定義控件,整個內容在屏幕上不可見。(需要滾動以查看所有內容)

用戶想要精確地打印面板在屏幕上的外觀,但是用戶希望整個面板在不滾動的情況下在屏幕上不可見。

如何在多頁中捕獲和打印整個面板?

任何幫助表示贊賞。

這可能對您有幫助。

    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