110,561
社区成员
发帖
与我相关
我的任务
分享
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim B As New Bitmap(Button1.Width, Button1.Height)
Using G As Graphics = Graphics.FromImage(B)
G.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
Using Gp As New Drawing2D.GraphicsPath
'绘制从边缘向内收缩4像素的椭圆
Gp.AddEllipse(New Rectangle(4, 4, Button1.Width - 8, Button1.Height - 8))
'设置按钮形状为该椭圆形状
Button1.Region = New Region(Gp)
'填充渐变
G.FillPath(New Drawing2D.LinearGradientBrush(New Point(4, 4), New Point(4, Button1.Height), Color.Yellow, Color.Red), Gp)
'描绘椭圆边框
G.DrawEllipse(New Pen(Brushes.Black, 3), New Rectangle(4, 4, Button1.Width - 8, Button1.Height - 8))
End Using
End Using
With Button1
'设置为其背景,不影响Image属性
.BackgroundImage = B
'取消难看的自有边框
.FlatAppearance.BorderSize = 0
'使用“抬起”效果是为了使按钮文字有点击响应视觉
.FlatStyle = FlatStyle.Popup
End With
End Sub