如何在引用特定行数后显示消息 [英] How to display message after priting specific number of lines

查看:66
本文介绍了如何在引用特定行数后显示消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



以下是我用于打印每页特定行数的代码



Hi all

Below is the code i am using for printing specific number of lines per page

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            float linesPerPage = 0;
            float yPos = 0;
            int count = 0;
            float leftMargin = e.MarginBounds.Left;
            float topMargin = e.MarginBounds.Top;
            string line = null;
            

            // Calculate the number of lines per page.
            linesPerPage = 30;

         
                //MessageBox.Show("Turn the page to continue");

                // Print each line of the file. 
                while (count < linesPerPage &&
                   ((line = streamToPrint.ReadLine()) != null))
                {

                    yPos = topMargin + (count *
                    printFont.GetHeight(e.Graphics));
                    e.Graphics.DrawString(line, printFont, Brushes.Black,
                       leftMargin, yPos, new StringFormat());
                    count++;

                }

              
                if (line != null)
                {
                    e.HasMorePages = true;
                   

                }
                else
                {
                    e.HasMorePages = false;
                }





但是这里假设用户有40行要打印,所以那时候我要在打印后显示一个消息框30行。

一旦用户调整页面或放入新页面,它将打印剩余的交易。



请帮我怎么做这个..



But here suppose user has 40 lines to print, so at that time i want to display one messagebox after printing 30 lines.
once user tuen the page or put new page, it will print the remaining transactions.

Please help me how to do this..

推荐答案

看看例子:



Have a look at example:

while (count < linesPerPage &&
   ((line = streamToPrint.ReadLine()) != null))
{
//here the condition is true and
//lines are printed to the limit
}

//check: limit was reached or there is no more lines
if (line != null)
{
    //limit was reached
}
else
{
    //no more lines ;)
}





现在,你知道在哪里显示消息吗?



正如我所提到的这很简单;)



Now, do you know where to display message?

As i mentioned it's quite simple ;)


这篇关于如何在引用特定行数后显示消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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