1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| Imports System.ComponentModel
Public Class MonTextBox
Inherits System.Windows.Forms.TextBox
Private _BorderColor As Color = Color.Red
Private _CurrentColor As Color
Private _BorderWidth As SByte = 1
Public Sub New()
Me.BorderStyle = Windows.Forms.BorderStyle.FixedSingle
End Sub
<Browsable(True), Category("Apparence")> _
Public Property BorderColor() As Color
Get
Return _BorderColor
End Get
Set(ByVal value As Color)
_BorderColor = value
_CurrentColor = value
Me.Invalidate()
End Set
End Property
<Browsable(True), Category("Apparence")> _
Public Property BorderWidth() As SByte
Get
Return _BorderWidth
End Get
Set(ByVal value As SByte)
_BorderWidth = value
Me.Invalidate()
End Set
End Property
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim mypen As Pen
mypen = New Pen(_CurrentColor, _BorderWidth)
e.Graphics.DrawRectangle(mypen, _BorderWidth, _BorderWidth, Me.Width - 2 * _BorderWidth, Me.Height - 2 * _BorderWidth)
End Sub
Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
_CurrentColor = _BorderColor
Me.Invalidate()
End Sub
Protected Overrides Sub OnLostFocus(ByVal e As System.EventArgs)
_CurrentColor = Color.Black
Me.Invalidate()
End Sub
End Class |
Partager