nazila a

nazila a

  • NA
  • 1
  • 1k

how to give a panel its exact size?

Aug 30 2014 2:08 AM
hi everyone. I'm not an English user,so forgive me for grammatical problems please. Smile | :)
I have some paper forms that i want to print some labels on them.these papers have special size(24 cm * 14).so I made a panel(907 pixel * 529 pixel) and i put my labels on it(I converted cm to pixel and i put labels in the special parts of my panel).these labels are going to be printed in empty fields of my paper forms.but the problem is that, just the first form can be printed in the right style.others are printed in upper place of the form. I thought it may be because of I didn't give my panel and labels exact size in pixel. but i couldn't give my panel exact size in pixels,coz it doesn't accept pixels in decimal. any ideas?
this is a part of my code:
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)         
{             
   Pen blackPen = new Pen(Color.Black, 1);             
   e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;             
   e.Graphics.DrawLine(blackPen, 188, 400, 302, 400);             
   e.Graphics.DrawRectangle(blackPen, 330, 319, 122, 55);             
   e.Graphics.DrawString(label20.Text, label20.Font, new SolidBrush(label20.ForeColor), label20.Location);             
   e.Graphics.DrawString(label21.Text, label21.Font, new SolidBrush(label21.ForeColor), label21.Location);             
   e.Graphics.DrawString(label23.Text, label23.Font, new SolidBrush(label23.ForeColor), label23.Location);             
   e.Graphics.DrawString(label24.Text, label24.Font, new SolidBrush(label24.ForeColor), label24.Location);             
   e.Graphics.DrawString(label25.Text, label25.Font, new SolidBrush(label25.ForeColor), label25.Location);             
   e.Graphics.DrawString(label26.Text, label26.Font, new SolidBrush(label26.ForeColor), label26.Location);             
   e.Graphics.DrawString(label27.Text, label27.Font, new SolidBrush(label27.ForeColor), label27.Location);             }
and the print region for each paper form:
System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument(); 
doc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage); 
PrintDialog PrintSettings = new PrintDialog(); PrintSettings.Document = doc; 
PageSettings pgsetting = new PageSettings(); 
doc.Print();