2015-09-01 101 views
0

「打印預覽」控制器顯示的不是第2頁或第3頁。如何在printpreview上顯示第二頁

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(); 
    } 

回答

0
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()的; 允許顯示下一頁。

相關問題