4
Reply

Print the contents of form

Mohammad Olwan

Mohammad Olwan

Mar 26 2016 3:23 PM
392
hello
I have form that content of labels and image and datagridview.
now i want to print this contents, for that, i use this snippet:
int i = 0;
while (i < DataGridView2.Rows.Count)
{
// regionone 
            if (y > e.MarginBounds.Height)
{
y = 50;
e.HasMorePages = true;
return;
}
// regionone-end 
if (DataGridView2.Rows[i].Cells[5].Value.ToString() == label10.Text)
{
e.Graphics.DrawString(DataGridView2.Rows[i].Cells[0].Value.ToString(), font , Brushes.Black, new Point(770, y + 7), format1);
..............
y += 35;
}
i++;
}
when i use this snippet, by using regionone  for produce more than one printed pages, but i have only one page Duplicated with the same data, and the remain contents did not printed at all.
when i change the place of regionone (put it befor if syntax, at the end of if syntax, at the first of while loop,.....) but i get only one printed page Duplicated.
when i remove "return;" i get  all required data on the (same) one page.
can you help me
Thank you 
 

Answers (4)