如何在printpreview上显示第二页



打印预览控制器显示第一页,而不是第2页或第3页。页面。

Show_Page()方法在列表视图中显示所有页面。

我用来改变页面打印预览控制器的方法如下:

为了显示下一页和上一页,我应该更改或添加什么?

    private void nxtBtn_Click(object sender, EventArgs e)
    {
        if (PrevIndex < PgCount)
            ++PrevIndex;
        if (PrevIndex == PgCount - 1)
            nxtBtn.Enabled = false;
        prvBtn.Enabled = true;
        ppd.PrintPreviewControl.InvalidatePreview();
        fName = GetFName();
        if (PublicVariables.PrintData == 2)
            Show_Page();
        else
        {
            pd.DocumentName = fName;
            ppd.Document = pd;
            ppc.Document = pd;
            ppc.Update();
        }
        label2.Text = (PrevIndex + 1).ToString();
    }

    private void ShowPage()
    {
        streamToRead = new StreamReader(fName, Encoding.UTF8);
        string line;
        int LineNbr = 0;
        li.Items.Clear();
        LineNbr = File.ReadAllLines(fName).Length;
        li.View = View.Details;
        int counter = 0;
        ListViewItem Lvi = new ListViewItem();
        char sep='|';
        int ctr_limit=0;
        if (PublicVariables.Grup_It == 0)
            ctr_limit = 9;
        else
            ctr_limit = 7;
        string[] tmp1 = new string[ctr_limit];
        while (counter < LineNbr && (line = streamToRead.ReadLine()) != null)
        {
            if (PublicVariables.PrintData == 2 && counter < 3)
                goto NextLine;
            string[] tmp = line.Split(sep);
            for (int i = 0; i < ctr_limit; ++i)
            {
                if (PublicVariables.Grup_It > 0)
                    tmp1[i] = tmp[i + 1];
                else
                    tmp1[i] = tmp[i];
            }
            Lvi = new ListViewItem(tmp1);
            li.Items.Add(Lvi);
        NextLine:
            ++counter;
        }
        streamToRead.Close();
    }
private void nxtBtn_Click(object sender, EventArgs e)
{
    if (PrevIndex < PgCount)
        ++PrevIndex;
    if (PrevIndex == PgCount - 1)
        nxtBtn.Enabled = false;
    prvBtn.Enabled = true;
    ppd.PrintPreviewControl.InvalidatePreview();
    fName = GetFName();
    if (PublicVariables.PrintData == 2)
        Show_Page();
    else
    {
        pd.DocumentName = fName;
        ppd.Document = pd;
        ppc.Document = pd;
        ppc.InvalidatePreview();
    }
    label2.Text = (PrevIndex + 1).ToString();
}

代替ppc.Update()我必须写ppc.InvalidatePreview();这允许显示下一页

相关内容

  • 没有找到相关文章

最新更新