| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2954 人关注过本帖
标题:用VB.NET如何画网格
只看楼主 加入收藏
xo1437404152
Rank: 1
等 级:新手上路
帖 子:17
专家分:1
注 册:2014-3-19
结帖率:100%
收藏
 问题点数:0 回复次数:2 
用VB.NET如何画网格
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: VB.NET 网格 
2018-01-06 20:53
zcsor
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:19
专家分:105
注 册:2018-2-5
收藏
得分:0 
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

        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)
        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, 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
2018-02-16 10:46
zcsor
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:19
专家分:105
注 册:2018-2-5
收藏
得分:0 
加上字符位置矫正就是这样
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
2018-02-16 10:50
快速回复:用VB.NET如何画网格
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025947 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved