跳转到C1PrintDocument中的页面

Jump to Page in C1PrintDocument

我的应用程序中有一个用于预览报表的表单。它在顶部有一个包含导航按钮的 C1Ribbon,以及一个显示在 PreviewPane 中的 C1PrintPreview。 我想要功能区中的导航按钮(第一个、上一个、下一个、最后一个),以及一个用于输入特定页码的文本框,以相应地浏览报表的预览。到目前为止,我发现的所有文档和示例都只涉及将超链接直接添加到报告本身……所以我很难适应它以适应我的使用。 下面是我目前所拥有的......我没有得到任何构建或 运行-time 错误,它只是没有做任何事情。

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" 方法(希望它那么简单)。功能区中的按钮没有超链接 属性,因此我无法像在我找到的所有示例中那样在加载表单时设置它。不知道从这里去哪里...... 另外我什至不知道我应该如何使用绝对 PageJumpTypeEnum...PageNo 是只读的。

谢谢!

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

他们的关键是 "PreviewPane.StartPageIdx"

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