VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > VB.net教程 >
  • vb.net教程之打印文字

.打印文字。
方法一:在窗体上打印文字
 Dim g As Graphics = Me.CreateGraphics  
    Dim mBrush As New SolidBrush(Color.Red) 
    Dim mFont As New Font("宋体", 18) 
g.DrawString("测试", mFont, mBrush, 0, 10)
(0 为横坐标,10 为纵坐标)
方法二:在窗体上画文字
        Dim m As Graphics
        m = Me.CreateGraphics
        m.DrawString("This is a diagonal line drawn on the control", _
          New Font("Arial", 10), Brushes.Gold, New PointF(300.0F, 444.0F))
        m.Dispose()
方法三:在图片框上打印文字
 
Public Class Form2
    ' This example creates a PictureBox control on the form and draws to it.
    ' This example assumes that the Form_Load event handler method is connected
    ' to the Load eventof the form.
    Private pictureBox1 As New PictureBox()
 
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' Dock the PictureBox to the form andset its background to white.
        pictureBox1.Dock = DockStyle.Fill
        pictureBox1.BackColor = Color.White
        ' Connect the Paint eventof the PictureBox to the event handler method.
Ø AddHandler pictureBox1.Paint, AddressOf Me.pictureBox1_Paint
 
        ' Add the PictureBox control to the Form.
        Me.Controls.Add(pictureBox1)
    End Sub 'Form1_Load
00:00:03.9522260
 
    Private Sub pictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
        ' Create a local version of the graphics objectfor the PictureBox.
        Dim g As Graphics = e.Graphics
 
        ' Draw a stringon the PictureBox.
        g.DrawString("This is a diagonal line drawn on the control", _
            New Font("Arial", 10), Brushes.Red, New PointF(30.0F, 30.0F))
        ' Draw a line in the PictureBox.
        g.DrawLine(System.Drawing.Pens.Red, PictureBox1.Left, _
            PictureBox1.Top, PictureBox1.Right, PictureBox1.Bottom)
    End Sub 'pictureBox1_Paint
 
 
End Class

相关教程