你说得没错,就是这样画,让你看看吧~这是一个打报表的例子
private float PrintPageHeader(System.Drawing.Printing.PrintPageEventArgs e)
{
try
{
float yPos =
e.MarginBounds.Top;
String line=null;
Font printTitleFont= new Font("新细明体",18,FontStyle.Bold);
Font printHeaderFont= new Font("新细明体",18,FontStyle.Bold);
StringFormat sfCenter= new StringFormat();
sfCenter.Alignment = StringAlignment.Center;
StringFormat sfRight= new StringFormat();
sfRight.Alignment = StringAlignment.Far;
StringFormat sfLeft= new StringFormat();
sfLeft.Alignment = StringAlignment.Near ;
//print company name
line="恒逸资讯股份有限公司";
e.Graphics.DrawString (line, printTitleFont, Brushes.Black, new RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height), sfCenter);
yPos+=printTitleFont.GetHeight(e.Graphics);
//print report name
line="讨论区报表";
e.Graphics.DrawString (line, printTitleFont, Brushes.Black, new RectangleF(e.MarginBounds.Left, e.MarginBounds.Top+printTitleFont.GetHeight(e.Graphics), e.MarginBounds.Width, e.MarginBounds.Height), sfCenter);
e.Graphics.DrawString ("列印日期:" +DateTime.Now.ToString("yyyy-MM-dd",null)
, mPrintFont, Brushes.Black, new RectangleF(e.MarginBounds.Left, e.MarginBounds.Top+printTitleFont.GetHeight(e.Graphics), e.MarginBounds.Width, e.MarginBounds.Height), sfRight);
yPos+=printHeaderFont.GetHeight(e.Graphics);
//print first line
e.Graphics.DrawLine(new Pen(Color.Black,4),e.MarginBounds.Left,yPos,e.MarginBounds.Right ,yPos);
yPos+=4;
//print column header
e.Graphics.DrawString ("主题代码", mPrintFont, Brushes.Black, new RectangleF(e.MarginBounds.Left, yPos, e.Graphics.MeasureString("主题代码",mPrintFont).Width, mPrintFont.GetHeight(e.Graphics)), sfLeft);
e.Graphics.DrawString ("发布日期", mPrintFont, Brushes.Black, new RectangleF(e.MarginBounds.Left+e.Graphics.MeasureString("主题代码 ",mPrintFont).Width, yPos, e.Graphics.MeasureString("0000-00-00",mPrintFont).Width, mPrintFont.GetHeight(e.Graphics)), sfLeft);
e.Graphics.DrawString ("发布者"
, mPrintFont, Brushes.Black, new RectangleF(e.MarginBounds.Left+e.Graphics.MeasureString("主题代码 0000-00-00
",mPrintFont).Width, yPos, e.Graphics.MeasureString("发布者发布者",mPrintFont).Width, mPrintFont.GetHeight(e.Graphics)), sfLeft);
e.Graphics.DrawString ("主题"
, mPrintFont, Brushes.Black, new RectangleF(e.MarginBounds.Left+e.Graphics.MeasureString("主题代码 0000-00-00
发布者发布者 ",mPrintFont).Width, yPos, e.MarginBounds.Width-(e.MarginBounds.Left+e.Graphics.MeasureString("主题代码 0000-00-00 发布者发布者 ",mPrintFont).Width)
, mPrintFont.GetHeight(e.Graphics)), sfLeft);
yPos+=mPrintFont.GetHeight(e.Graphics);
//print 2nd line
e.Graphics.DrawLine(new Pen(Color.Black,4),e.MarginBounds.Left,yPos,e.MarginBounds.Right ,yPos);
yPos+=4;
//print page no
float lpp = (e.MarginBounds.Height- yPos)
/ mPrintFont.GetHeight(e.Graphics) ;
mTotalPageCount=(mDataSet1.Tables["forum"].Rows.Count / Convert.ToInt32( lpp))
+1 ;
e.Graphics.DrawString ("页数:"+mCurrentPageNo.ToString()+"/"+mTotalPageCount.ToString()
, mPrintFont, Brushes.Black, new RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height), sfRight);
return yPos;
}
catch(System.Exception E)
{
ErrorHandler(E.ToString());
return 0;
}
}
用Graphics画我觉得蛮方便的啊~哪里不行呢?晕晕的...