回 帖 发 新 帖 刷新版面

主题:大家帮我这个菜鸟改改错误,不胜感激

题目是打印椭圆的三个页面,颜色分别是红,绿,蓝,我的代码如下:在vb.net下编译

Public Class Form1
    Inherits System.Windows.Forms.Form
Windows 窗体设计器生成的代码(省略)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        PrintDialog1.Document = PrintDocument1
        PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings
        PrintDialog1.AllowSomePages = True
        If PrintDialog1.ShowDialog = DialogResult.OK Then
            PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings
            PrintDocument1.Print()

        End If
    End Sub

    Dim intpage As Integer
    Private Sub PrintDocument1_BeginPrint(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.BeginPrint
        intpage = 0
    End Sub

    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        intpage += 1
        Select Case intpage
            Case 1
                e.Graphics.FillEllipse(Brushes.Red, 100, 200, 680, 500)
            Case 2
                e.Graphics.FillEllipse(Brushes.Green, 100, 200, 680, 500)
            Case 3
                e.Graphics.FillEllipse(Brushes.Blue, 100, 200, 680, 500)
                e.HasMorePages = True

        End Select
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        PrintPreviewDialog1.Document = PrintDocument1
        PrintPreviewDialog1.ShowDialog()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        PageSetupDialog1.Document = PrintDocument1
        PageSetupDialog1.PageSettings = PrintDocument1.DefaultPageSettings
        PageSetupDialog1.PrinterSettings = PrintDocument1.PrinterSettings
        If PageSetupDialog1.ShowDialog = DialogResult.OK Then
            PrintDocument1.DefaultPageSettings = PageSetupDialog1.PageSettings
            PrintDocument1.PrinterSettings = PageSetupDialog1.PrinterSettings
        End If
    End Sub
End Class
[font=黑体][/font]

回复列表 (共1个回复)

沙发

在编译的时候,系统提示
Private Sub PrintDocument1_BeginPrint(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.BeginPrint
这条语句有错误,说“方法”“PrintDocument1.BeginPrint”无法处理事件“BeginPrint”原因是他们不具有相同的签名


谁帮我改一下,谢谢

我来回复

您尚未登录,请登录后再回复。点此登录或注册