打印文档控件中的绘制字符串 [英] drawing string in printdocument control

查看:80
本文介绍了打印文档控件中的绘制字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.我想在运行时在printcodument控件中绘制一个字符串.我该怎么办?

Hi All. I want to draw a string in a printcodument control at runtime. What can i do?

推荐答案

这很容易:比.NET容易得多!
您所要做的就是:
1)构造一个PrintDocument.
2)添加一个PrintPage事件处理程序
3)告诉文件打印
4)在事件处理程序中,使用DrawString方法

It''s pretty easy: a heck of a lot easier than it was before .NET!

All you have to do is:
1) Construct a PrintDocument.
2) Add a PrintPage Event handler
3) Tell the document to print
4) In the event handler, use the DrawString method

private void MyPrintDocument_PrintPage(object sender, PrintPageEventArgs ev)
    {
    ev.Graphics.DrawString("Hello!", printFont, Brushes.Black, 20, 20);
    ev.HasMorePages = false;
    }



如果您查看MSDN,则有一个完整的示例: PrintDocument [ ^ ]



If you look at MSDN, there is a complete example: PrintDocument[^]


这篇关于打印文档控件中的绘制字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆