none
vb2008在窗体上画了一个直线,能否打印出来呢 RRS feed

  • 问题

  • 已经写代码画出了直线,想问问怎麽能打印机打印出来,最好写代码在窗体上一共画出同样的10条直线,然后打印,谢谢【按钮是自己随便加的】

    Imports System.Drawing


    Public Class Form1

        Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            On Error Resume Next
            Dim g As Graphics
            g = Me.CreateGraphics
            Dim p As New Pen(Color.Red, 2)
            Dim p6 As New Pen(Color.Blue, 1)
            Dim f As New Font("宋体", 10, FontStyle.Underline), sb As New SolidBrush(Color.Black)
            Dim p1, p2 As New Point
            Dim y1, i, j, a, b As Single
            a = Me.Width / 2
            y1 = Me.Height / 2
            b = 5
            p1 = New Point(0, y1)
            p2 = New Point(2 * a, y1)
            g.DrawLine(p, p1, p2)
            Dim p4(28), p5(28) As PointF

            For i = 0 To 30
                j = 0 + i * 50
                p4(i) = New PointF(j, y1)
                p5(i) = New PointF(j, y1 - 5)
                If j <= 2 * a Then
                    g.DrawLine(p6, p4(i), p5(i))
                    g.DrawString(i, f, sb, j, y1 + 10)
                End If
            Next i
            g.DrawString("直线", f, sb, 0, y1 + 30)

        End Sub

    End Class


    • 已编辑 h01123 2012年11月13日 12:46
    2012年11月13日 12:44

答案