I have a win form where i have some label
,a datagridview
and some textbox
.I want to print all of my items in my form in exact format it shows in the form. I have tried it using taking snap of my form then print it. But in this way i can't have my full form as my form is large enough.It only shows half portion of my form.I don't know is it the best practice on not.Is there any other way of doing this please mention
My Sample code:
private void btnPrint_Click(object sender, EventArgs e)
{
CaptureScreen();
printDocument1.Print();
}
private void CaptureScreen()
{
Graphics myGraphics = this.CreateGraphics();
Size s = this.Size;
memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
memoryGraphics.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s);
}
private void printDocument1_PrintPage_1(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryImage, 0, 0);
}
As i am new in C#,it will be great help if anyone help me with some sample code.