Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

textbox border color

Status
Not open for further replies.

hackproof

Programmer
Feb 29, 2004
41
0
0
PH
Hi guys,

Do you know how to change the border color of textbox? I'm working on a project and a client of mine insist on highlighting textbox objects that require a user input by having red border color of text box. Could anyone help me on this one?
 
I cant see any obvious way, and there is also no Paint or Draw event to override.

One solution is to create a custom control consisting of a panel with a textbox inside it, docked full, with the panel having a dockpadding of 2 for all sides. Then simply set the panels backcolor to get the desired effect



Sweep
...if it works dont f*** with it
...if its f****ed blame someone else
...if its your fault that its f***ed, say and admit nothing.
 
Another method you could try is using the form paint event to draw a rectangle around the textbox.
It acts as more of a highlight rather than a border color as the original black still shows but still looks OK for a workaround.
Code:
 Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        Dim g As Graphics = e.Graphics
        Dim p As New Pen(Color.Red, 2)
        g.DrawRectangle(p, TextBox1.Left, TextBox1.Top, TextBox1.Width, TextBox1.Height)

    End Sub
 
Just as a note, I'm using the "FixedSingle" border style rather than "Fixed3D" for the above example.
 
you could also set the borderstyle to none

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
and taking a really wild guess that might just solve the problem with the original border still showing. God if I had half a brain I'd be scary.
 
thanks guys, so sure know your vb .net. thanks a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top