改变控件的边框颜色(示例Label)
2007-11-15 18:23
375 查看
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
相关文章推荐
- Delphi给窗体镶边-为控件加边框,描边,改变边框颜色
- Delphi给窗体镶边-为控件加边框,描边,改变边框颜色
- C#中改变DataGridView控件边框颜色的方法
- 改变Label不同的字显示不同的颜色
- label 省略号颜色改变
- winfrom 树形控件如何实现鼠标经过节点时光标颜色改变效果
- 微软的GroupBox边框颜色的改变 ~!
- C# WinForm窗体控件Panel修改边框颜色以及边框宽度方法
- VC中如何改变对框中控件的颜色
- 工控图表控件ProEssentials改变子集的颜色和线条风格
- mfc里的text控件改变颜色
- 使用OnCtlColor函数来改变控件颜色
- 怎样让选中的label 改变颜色?
- table动态改变颜色包括一个边框
- [原创]table动态改变颜色包括一个边框
- 改变Repeater控件中按钮颜色
- 一条语句改变进度条颜色及去掉进度条边框
- Android在监听器中使用代码改变其他控件背景或颜色
- VC中如何改变对框中控件的颜色
- Qt控件改变字体大小颜色