在我的 flowlayoutpanel 中打印用户控件集合

问题描述

我的 flowlayout 面板中有一组用户控件,我想使用 printdocument 每页打印用户控件。有没有其他方法可以解决我的问题?

我在我的 printpage 方法中尝试了这段代码 -

    for (int i = numberOfItemsPrintedSoFar; i < chequeContainer.Controls.Count; i++)
    {
        numberOfItemsPerPage++;
        if (numberOfItemsPerPage <= 3)
        {
            numberOfItemsPrintedSoFar++;

            if (numberOfItemsPrintedSoFar <= chequeContainer.Controls.Count)
            {
                 foreach (ClassForGettingData data in ClassForGettingData.cheque_list)
                {
                    CustomUsercontrol u = new CustomUsercontrol );
                    u.chequeInfos(data);
                    u.PrintToGraphics(e.Graphics,new Point(0,yPos));
                    yPos += 450;
                }
            }
            else
            {
                e.HasMorePages = false;
            }
        }
        else
        {
            numberOfItemsPerPage = 0;
            e.HasMorePages = true;
            return;
        }
    }
}
numberOfItemsPerPage = 0;
numberOfItemsPrintedSoFar = 0;
internal void PrintToGraphics(Graphics graphics,Point point)
{
    Bitmap bitmap = new Bitmap(this.Width,this.Height);
    this.DrawToBitmap(bitmap,new Rectangle(0,bitmap.Width,bitmap.Height));

    graphics.PageUnit = GraphicsUnit.Display;
    graphics.DrawImage(bitmap,point);
}

但是这段代码的问题是它只在一页文档中打印了所有控件。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...