惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
The Exploit Database - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
Simon Willison's Weblog
Simon Willison's Weblog
T
Tor Project blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
D
DataBreaches.Net
The Hacker News
The Hacker News
有赞技术团队
有赞技术团队
Latest news
Latest news
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threat Research - Cisco Blogs
G
GRAHAM CLULEY
G
Google Developers Blog
W
WeLiveSecurity
Project Zero
Project Zero
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
MyScale Blog
MyScale Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
F
Full Disclosure
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
F
Fortinet All Blogs
PCI Perspectives
PCI Perspectives
小众软件
小众软件
N
News | PayPal Newsroom
罗磊的独立博客
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
AI
AI
T
Tenable Blog
S
Schneier on Security
O
OpenAI News
The Register - Security
The Register - Security
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
T
Threatpost
Hacker News: Ask HN
Hacker News: Ask HN

博客园 - 奚彧

Siverlight 导出Excel (经测试通过 Vs2010 ,silverlight5 ) 部署silverlight ria 程序 备忘 刚学 silverlight 问题遇到一堆 2010 微软难道抛弃了ado.net data service openfire 安装 关于DataSet.merge 问题的答案。 关于merge .net常用代码 (收藏) - 奚彧 - 博客园 碰到一个巨郁闷的情况! - 奚彧 - 博客园 关于连接池问题 删除确认按钮 - 奚彧 - 博客园 水晶报表自动插入空白行 也谈如何缩小SQL SERVER日志文件 新年第一帖,祝大家新年快乐! vs2005什么时候能出正式版 《WEB打印的相关技术分析》 web打印2 web打印 权限设置问题!(比较着急)
打印代码片段
奚彧 · 2013-10-05 · via 博客园 - 奚彧
//当前打印的行的索引,用于遍历ListBox.Items
        private int listPrintIndex;
        private void btnPrintList_Click(object sender, RoutedEventArgs e)
        {
            //初始值为0
            listPrintIndex = 0;
            PrintDocument document = new PrintDocument();
            document.PrintPage += new EventHandler<PrintPageEventArgs>(document_PrintPage);
            document.Print("Print List");
        }

        //设置每一项之间的间距
        private int extraMargin = 50;
        void document_PrintPage(object sender, PrintPageEventArgs e)
        {
            //定义一个打印的元素
            Canvas printSurface = new Canvas();
            e.PageVisual = printSurface;
            //得到最顶端位置
            double topPosition = e.PageMargins.Top + extraMargin;

            //遍历当前的ListBox.Items
            while (listPrintIndex<lstPrint.Items.Count)
            {
                //实例化TextBlock用来存放ListItem的值
                TextBlock txt = new TextBlock();
                txt.FontSize = 30;
                //得到ListBox每一项的值
                txt.Text = lstPrint.Items[listPrintIndex].ToString();
                double measuredHeight = txt.ActualHeight;
                //如果打印的当前行高度不合适的话,则进行分页
                if (measuredHeight>(e.PrintableArea.Height- topPosition- extraMargin))
                {
                    e.HasMorePages = true;
                    return ;
                }

                //设置TextBlock在Canvas中的位置
                txt.SetValue(Canvas.TopProperty, topPosition);
                txt.SetValue(Canvas.LeftProperty, e.PageMargins.Left + extraMargin);
                //将TextBlock添加到打印的元素中去
                printSurface.Children.Add(txt);

                listPrintIndex++;
                //追加高度
                topPosition = topPosition + measuredHeight;
            }
            e.HasMorePages = false;
        }