2015-02-23 135 views
0

我的應用程序中有一個用於預覽報表的表單。它在頂部有一個包含導航按鈕的C1Ribbon,以及一個在PreviewPane中顯示的C1PrintPreview。 我希望功能區(第一個,上一個,下一個,最後一個)中的導航按鈕以及用於輸入特定頁碼的文本框相應地瀏覽報表預覽。到目前爲止,我發現的所有文檔和示例都只涉及將超鏈接直接添加到報表本身......所以我很難適應我的使用。 下面是我到目前爲止...我沒有得到任何生成或運行時錯誤,它只是沒有做任何事情。跳轉到C1PrintDocument中的頁面

Private Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click 
    Dim nextPage As C1LinkTargetPage = New C1LinkTargetPage(PageJumpTypeEnum.Next) 
End Sub 

Private Sub btnLast_Click(sender As Object, e As EventArgs) Handles btnLast.Click 
    Dim lastPage As C1LinkTargetPage = New C1LinkTargetPage(PageJumpTypeEnum.Last) 
End Sub 

Private Sub btnPrevious_Click(sender As Object, e As EventArgs) Handles btnPrevious.Click 
    Dim prevPage As C1LinkTargetPage = New C1LinkTargetPage(PageJumpTypeEnum.Previous) 
End Sub 

Private Sub btnFirst_Click(sender As Object, e As EventArgs) Handles btnFirst.Click 
    Dim firstPage As C1LinkTargetPage = New C1LinkTargetPage(PageJumpTypeEnum.First) 
End Sub 

Private Sub Navigation_KeyDown(sender As Object, e As KeyEventArgs) Handles txtPageNum.KeyDown 
    If e.Modifiers = Keys.Enter Then 
     Dim setPage As C1LinkTargetPage = New C1LinkTargetPage(PageJumpTypeEnum.Absolute) 
     'setPage. = CInt(txtPageNum.Text) 
     If setPage.PageNo = 0 Then 
      'what to do if number entered is not a page in document 
     End If 
    End If 
End Sub 

我意識到這可能只是因爲即使我做一個C1LinkTargetPage,我不說什麼應用程序,用它做之後。但我不知道該怎麼做 - 這不像C1PrintPreview有一個「jumptopage」方法(希望它很簡單)。功能區中的按鈕沒有超鏈接屬性,所以當表單加載時我無法設置該按鈕,因爲我找到的所有示例都是這樣。不知道從哪裏去... 此外,我甚至不知道我應該如何使用Absolute PageJumpTypeEnum ... PageNo是隻讀的。

謝謝!

UPDATE 2/25:

我才知道,我應該處理的預覽窗格......不是C1PrintDocument的性能。使用下面的代碼,導航按鈕和指定頁碼的工作。我現在唯一的問題就是在頁碼框中顯示當前頁面。與我所擁有的一樣,PreviewPane.CurrentHistoryEntry僅爲1(即使我之前的頁面不是1)。

Private Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click 
    PreviewPane.DoGoNextPage() 
End Sub 

Private Sub btnLast_Click(sender As Object, e As EventArgs) Handles btnLast.Click 
    Dim lastPage As DocumentLocation = New DocumentLocation(report.Pages(report.Pages.Count - 1)) 
    PreviewPane.GotoDocumentLocation(lastPage) 
End Sub 

Private Sub btnPrevious_Click(sender As Object, e As EventArgs) Handles btnPrevious.Click 
    PreviewPane.DoGoPreviousPage() 
End Sub 

Private Sub btnFirst_Click(sender As Object, e As EventArgs) Handles btnFirst.Click 
    Dim firstPage As DocumentLocation = New DocumentLocation(report.Pages(0)) 
    PreviewPane.GotoDocumentLocation(firstPage) 
End Sub 

Private Sub Navigation_KeyDown(sender As Object, e As KeyEventArgs) Handles txtPageNum.KeyDown 
    If e.KeyValue = Keys.Enter Then 
     Dim pageNum As Integer = CInt(txtPageNum.Text) 
     If (pageNum > 0) And (pageNum <= report.Pages.Count) Then 
      Dim setPage As DocumentLocation = New DocumentLocation(report.Pages(pageNum - 1)) 
      PreviewPane.GotoDocumentLocation(setPage) 
     Else 
      txtPageNum.Text = PreviewPane.CurrentHistoryEntry.ToString 
     End If 
    End If 
End Sub 

回答

0

它們鍵是 「PreviewPane.StartPageIdx」

txtPageNum.Text =(PreviewPane.StartPageIdx + 1)的ToString