在窗体上实现空心字
工具/原料
vs.net(vb.net)
方法/步骤
1
创建窗体form1添加按钮button1
2
双击button1进入代码编辑状态添加代码Imports System.Drawing.Drawing2D
3
为按钮添加代码 Dim g As Graphics = Me.CreateGraphics() Dim gp As New GraphicsPath() Dim stringText As String = '中华人民' Dim family As New FontFamily('宋体') '字体 Dim fontStyle__1 As Integer = CInt(FontStyle.Bold) '字体样式 Dim emSize As Integer = 100 '字体大小 Dim origin As New Point(20, 20) '文本的起始点,即左上角 Dim format As StringFormat = StringFormat.GenericDefault '默认的文本格式 gp.AddString(stringText, family, fontStyle__1, emSize, origin, format) '向路径添加文本字符串 'g.FillPath(new SolidBrush(Color.Black), gp); g.DrawPath(New Pen(Color.Red), gp) '把路径画出来 g.Dispose()
4
运行 点击按钮 查看效果
上一篇:word如何制作空心文字标题?