in this post you can learn about Text box Border Color and Size Change in VB.NET make the Text boxes then paste the below code.
Public Class Form1
Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
With TextBox1
Dim p As New Pen(If(TextBox1.Text <> "", Color.Green, Color.Red), 3)
e.Graphics.DrawRectangle(p, .Left - 1, .Top - 1, .Width + 2, .Height + 2)
p.Dispose()
End With
With TextBox2
Dim p As New Pen(If(TextBox2.Text <> "", Color.Green, Color.Red), 3)
e.Graphics.DrawRectangle(p, .Left - 1, .Top - 1, .Width + 2, .Height + 2)
p.Dispose()
End With
With TextBox3
Dim p As New Pen(If(TextBox3.Text <> "", Color.Green, Color.Red), 3)
e.Graphics.DrawRectangle(p, .Left - 1, .Top - 1, .Width + 2, .Height + 2)
p.Dispose()
End With
End Sub
Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged
Me.Invalidate()
End Sub
Private Sub TextBox2_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox2.TextChanged
Me.Invalidate()
End Sub
Private Sub TextBox3_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox3.TextChanged
Me.Invalidate()
End Sub
End Class
Post a Comment