关于C#datagridview 打印问题
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Graphics g = e.Graphics;
//每一页的行数
float MyLines = e.MarginBounds.Height / this.dataGridView1.Font.GetHeight(g);
//打印时的行计数器
int MyLineNumber = 0;
//打印时的纵坐标
float MyYPosition = 0;
float MyMarginLeft = e.MarginBounds.Left;
float MyMarginTop = e.MarginBounds.Top;
//每一行要打印的文本
string MyLine = "";
while ((MyLineNumber < MyLines) && ((MyLine = MyReader.ReadLine()) != null))
{
MyYPosition = MyMarginTop +
MyLineNumber * this.dataGridView1.Font.GetHeight(g);
g.DrawString(MyLine, this.dataGridView1.Font, new SolidBrush(Color.Black), MyMarginLeft, MyYPosition, new StringFormat());
MyLineNumber++;
}
if (MyLine != null)
{
//发出下一次PrintPage事件
e.HasMorePages = true;
}
else
{
e.HasMorePages = false;
}
}
我这样写对吗 取datagridview所有的值取的对吗