I have code for changing textbox border color on mouse click
but I could not get that how to implement it and where to implement it
here is the code:
using controlpaint.DrawBorder ,you can draw with penwidth greater than 1
Public Class HighlightTextBox
Inherits System.Windows.Forms.TextBox
'Default Highlight color is red.>>
Private Highlight_Color As Color = Color.Red
Public Property HighLightColor() As Color
Get
Return Me.Highlight_Color
End Get
Set(ByVal value As Color)
Me.Highlight_Color = value
End Set
End Property
Private Pen_Width As Integer = 1
Public Property PenWidth() As Integer
Get
Return Me.Pen_Width
End Get
Set(ByVal value As Integer)
Me.Pen_Width = value
End Set
End Property
Private Sub HiLightTextBox_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.GotFocus
Dim g As Graphics = Me.Parent.CreateGraphics
Dim Rect As New Rectangle(Me.Location.X - Me.Pen_Width, Me.Location.Y - Me.Pen_Width, Me.Width + Me.Pen_Width * 2, Me.Height + Me.Pen_Width * 2)
Windows.Forms.ControlPaint.DrawBorder(g, Rect, Me.Highlight_Color, Me.Pen_Width, Windows.Forms.ButtonBorderStyle.Solid, Me.Highlight_Color, Me.Pen_Width, _
Windows.Forms.ButtonBorderStyle.Solid, Me.Highlight_Color, Me.Pen_Width, Windows.Forms.ButtonBorderStyle.Solid, Me.Highlight_Color, Me.Pen_Width, Windows.Forms.ButtonBorderStyle.Solid)
End Sub
Private Sub HiLightTextBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus
Dim g As Graphics = Me.Parent.CreateGraphics
Dim Rect As New Rectangle(Me.Location.X - Me.Pen_Width, Me.Location.Y - Me.Pen_Width + Me.Pen_Width, Me.Width, Me.Height + Me.Pen_Width)
g.DrawRectangle(New Pen(Parent.BackColor, Me.Pen_Width), Rect)
Parent.Refresh()
End Sub
Private Sub HiLightTextBox_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
Me.Refresh()
Call HiLightTextBox_GotFocus(Nothing, Nothing)
End Sub
End Class
I have form1 and in that there is only textbox , so in it where to implement
Help me ..