i made a form that consists of labels !! this form is like an invoice .. all labels and lists contains the items and its const and at the end the total cost ..

now i have a print button, and i would like to print the contents of the labels??

how can i do this ??

pls help

[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern long BitBlt (IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
private Bitmap memoryImage;
private void CaptureScreen()
{
   Graphics mygraphics = this.CreateGraphics();
   Size s = this.Size;
   memoryImage = new Bitmap(s.Width, s.Height, mygraphics);
   Graphics memoryGraphics = Graphics.FromImage(memoryImage);
   IntPtr dc1 = mygraphics.GetHdc();
   IntPtr dc2 = memoryGraphics.GetHdc();
   BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, dc1, 0, 0, 13369376);
   mygraphics.ReleaseHdc(dc1);
   memoryGraphics.ReleaseHdc(dc2);
}
private void printDocument1_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
   e.Graphics.DrawImage(memoryImage, 0, 0);
}
private void printButton_Click(System.Object sender, System.EventArgs e)
{
   CaptureScreen();
   printDocument1.Print();
}

Hi try this.... it will print the entire form and its contents.. hope it helps...

Edited 5 Years Ago by vincezed: n/a

but does this become like a print screen?

since i dont want it like a print screen

One more suggestion: You can create a report (Crystal Report would be perfect), pass data of label to it, design it by your needs, and print it out.
Thats why Reports are made for.

In that case crystal report is the only option for u... and it is the best... try it

This question has already been answered. Start a new discussion instead.