|
|
#3
zcsor2018-02-16 10:50
加上字符位置矫正就是这样
Public Class Form1
Private WithEvents PnlShow As New Panel
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Size = New Size(600, 600)
PnlShow.Size = New Size(500, 500)
PnlShow.BorderStyle = BorderStyle.FixedSingle
PnlShow.Location = New Point(50, 50)
Me.Controls.Add(PnlShow)
End Sub
Private Sub PnlShow_Paint(sender As Object, e As PaintEventArgs) Handles PnlShow.Paint
Dim MaxX As Integer = PnlShow.Width - 25
Dim MaxY As Integer = PnlShow.Height - 25
Dim Offset = e.Graphics.MeasureString("2", Me.Font)
For y As Integer = 25 To MaxY Step 50
e.Graphics.DrawLine(Pens.Black, 25, y, MaxX, y)
e.Graphics.DrawString(y, Me.Font, SystemBrushes.AppWorkspace, MaxX + 5, y - Offset.Height / 2)
Next
For x As Integer = 25 To MaxX Step 50
e.Graphics.DrawLine(Pens.Black, x, 25, x, MaxY)
e.Graphics.DrawString(x, Me.Font, Brushes.Black, x - x.ToString.Length * Offset.Width / 2, MaxY + 5)
Next
e.Graphics.DrawBezier(Pens.Red, New Point(25, 25), New Point(50, 300), New Point(200, 400), New Point(450, 450))
End Sub
End Class
|