ws 窗体设计器所必需的。 InitializeComponent() '' 在 InitializeComponent() 调用之后添加任何初始化。 SetStyle(ControlStyles.AllPaintingInWmPaint, True) SetStyle(ControlStyles.ResizeRedraw, True) SetStyle(ControlStyles.UserPaint, True) SetStyle(ControlStyles.OptimizedDoubleBuffer, True) End Sub Dim _color As Color = Color.Red _ Public Property MyColor() As Color Get Return _color End Get Set(ByVal value As Color) _color = value End Set End Property Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e) Dim br As New SolidBrush(MyColor) Dim g As Graphics = e.Graphics Dim path As New GraphicsPath Dim path1 As New GraphicsPath Dim path2 As New GraphicsPath path.AddLine(New Point(0, 0), New Point(0, 9)) path.AddLine(New Point(0, 9), New Point(5, 5)) path.AddLine(New Point(5, 5), New Point(0, 0)) path.CloseAllFigures() path1.AddLine(New Point(Me.Width - 5, 5), New Point(Me.Width, 0)) path1.AddLine(New Point(Me.Width, 0), New Point(Me.Width, 9)) path1.AddLine(New Point(Me.Width, 9), New Point(Me.Width - 5, 5)) path1.CloseAllFigures() path2.AddRectangle(New Rectangle(5, 5, Me.Width - 5, 1)) path2.CloseAllFigures() Dim pen As New Pen(Color.Black, 2) g.FillPath(br, path) g.FillPath(br, path1) g.FillPath(br, path2) Dim re As New Region(path) re.Union(path2) re.Union(path1) Me.Region = re End SubEnd Classview plaincopy to clipboardprint?
- 说明:这个控件继承control