主题:大家帮我这个菜鸟改改错误,不胜感激
题目是打印椭圆的三个页面,颜色分别是红,绿,蓝,我的代码如下:在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]
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]