Imports System.Drawing.Drawing2D
Public Class VistaLabelClass VistaLabel
Inherits Label
Private ChangeColor As Boolean
Private _BorderColor As Color = Color.Transparent

Public Property BorderColor()Property BorderColor() As Color
Get
Return _BorderColor
End Get
Set(ByVal value As Color)
_BorderColor = value
End Set
End Property

Private Sub VistaLabel_MouseLeave()Sub VistaLabel_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave
MyBase.BackColor = Color.Transparent
ChangeColor = False
End Sub

Private Sub VistaLabel_MouseMove()Sub VistaLabel_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
MyBase.BackColor = Color.FromArgb(235, 247, 255)
ChangeColor = True
End Sub

Private Sub VistaLabel_Paint()Sub VistaLabel_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
If ChangeColor = True Then
e.Graphics.DrawRectangle(DirectCast(New Pen(_BorderColor), Pen), 0, 0, Me.Width - 1, Me.Height - 1)
Else
e.Graphics.DrawRectangle(Pens.Transparent, 0, 0, Me.Width - 1, Me.Height - 1)
End If
End Sub
End Class
本文介绍了一个名为VistaLabelClass的自定义Label控件,该控件允许用户改变边框颜色。当鼠标离开控件时,边框颜色会变为透明;鼠标在控件上移动时,背景色变为淡蓝色并显示边框颜色。通过BorderColor属性可以设置边框颜色。
1万+

被折叠的 条评论
为什么被折叠?



