c# 拼凑特定格式的报表打印

private void button4_Click(object sender, EventArgs e)
{
this.printDocument1.DocumentName = this.label27.Text;

this.printDocument1.Print();
}

private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.Clear(Color.White);
// 开始绘制文档
// 默认为横排文字
e.Graphics.DrawString("标题", 
                                    new Font(new FontFamily("宋体"), 22, FontStyle.Bold), 
                                    System.Drawing.Brushes.Black, 
                                    170, 10);
e.Graphics.DrawString("性别:" + this.comboBox1.Text,
new Font(new FontFamily("宋体"), 14, FontStyle.Bold),
System.Drawing.Brushes.Black,
20, 50);
e.Graphics.DrawString("联系电话:" + this.textBox9.Text,
new Font(new FontFamily("宋体"), 14, FontStyle.Bold),
System.Drawing.Brushes.Black,
350, 50);
e.Graphics.DrawString("地址:" + this.textBox11.Text,
new Font(new FontFamily("宋体"), 14, FontStyle.Bold),
System.Drawing.Brushes.Black,
20, 80);
// 横线
e.Graphics.DrawLine(Pens.Black, 20, 110, 800, 110);
// 竖排文字
e.Graphics.DrawString("内容",
new Font(new FontFamily("宋体"), 14, FontStyle.Bold),
System.Drawing.Brushes.Black,
20, 120,
new StringFormat(StringFormatFlags.DirectionVertical));

}

posted @ 2019-01-22 15:39  huangkeke  阅读(361)  评论(0)    收藏  举报