当前位置:编程学习 > C#/ASP.NET >>

textbox打印的问题。

写了个小程序,计算结果放在textbox里面。想再加一个打印button,使计算结果可以直接打印,请问该怎么实现?    例如计算结果是a=2,b=3,c=4,打印出来最好能有个表格就更好了,可以更直观的显示出打印结果。谢谢大家了。 --------------------编程问答-------------------- 添加printDocument控件,然后在printDocument的PrintPage事件中
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e) 

Graphics g = e.Graphics; //获得绘图对象 
float linesPerPage = 0; //页面的行号 
float yPosition = 0; //绘制字符串的纵向位置 
float xPosition = 0; 
int count = 0; //行计数器 
float leftMargin = e.MarginBounds.Left; //左边距 
float topMargin = e.MarginBounds.Top; //上边距 
string line = null; //行字符串 
Font printFont = this.textBoxf1.Font; //当前的打印字体 
SolidBrush myBrush = new SolidBrush(Color.Black);//刷子 
linesPerPage = e.MarginBounds.Height / printFont.GetHeight(g);//每页可打印的行数 
//逐行的循环打印一页 
while (count < linesPerPage && ((line = s1.ReadLine()) != null)) 

yPosition = topMargin + (count * printFont.GetHeight(g))-35 ; 
xPosition = leftMargin + (count * printFont.GetHeight(g))+30 ; 
g.DrawString(line, printFont, myBrush, xPosition , yPosition, new StringFormat()); 
count++; 

while (count < linesPerPage && ((line = s2.ReadLine()) != null)) 

yPosition = topMargin + (count * printFont.GetHeight(g)) -50; 
xPosition = leftMargin + (count * printFont.GetHeight(g)) +540 ; 
g.DrawString(line, printFont, myBrush, xPosition, yPosition, new StringFormat()); 
count++; 

s1 = new StringReader(textBoxd1.Text); 
}  --------------------编程问答-------------------- vs自带有打印控件 百度下  --------------------编程问答--------------------  打印控件使用
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,