0

I can't seem to find much help on printing FlowLayoutPanels in C#

I basically have a FlowLayoutPanel with multiple panels inside it. Each panel has textboxes and labels on it.

I want to print the entire contents of the flowlayoutpanel regardless of whether you need to scroll down. and that have many pages. I have tried the below :

   private void doc_PrintPage(object sender, PrintPageEventArgs e)
    {
     Bitmap bmp = new Bitmap(flowlayoutpanel.Width, flowlayoutpanel.Height, 
     flowlayoutpanel.CreateGraphics());
     flowlayoutpanel.DrawToBitmap(bmp, new Rectangle(0, 0, flowlayoutpanel.Width, flowlayoutpanel.Height));
     RectangleF bounds = e.PageSettings.PrintableArea;
     float factor = ((float)bmp.Height / (float)bmp.Width);
     e.Graphics.DrawImage(bmp, bounds.Left, bounds.Top, bounds.Width, factor * bounds.Width);
    }

   private void btnsave_Click(object sender, EventArgs e)
        {
            PrintDocument doc = new PrintDocument();
            doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);
            doc.Print();
        }

this code print just some panels that when scrool is up but other panel from the button not printed.

Sorry for my english.

  • A FlowLayoutPanel is a control. So see following : https://stackoverflow.com/questions/24717247/print-the-entire-area-of-the-control-with-c-sharp – jdweng May 30 '20 at 13:43
  • 2
    https://stackoverflow.com/a/57257205/10216583 –  May 30 '20 at 14:01

0 Answers0