Click here to Skip to main content
15,891,012 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've been using a really nice code that draws a border around a textbox with no border. I really like it but I'd much rather have a dashed or dotted border. Is there a way to draw a dashed border around every textbox on my form?

I've been working with the code for a while and I have yet to figure it out some insight of that is possible would be awesome! Thanks for the help!

Code below works great but need dashed or dotted lines!

What I have tried:

<br />
Dim g As Graphics = e.Graphics<br />
Dim pen As New Pen(ColorTranslator.FromHtml(normalFontColor), 2.0)<br />
Dim txtBox As Control<br />
For Each txtBox In Me.Controls<br />
    If TypeOf (txtBox) Is TextBox Then<br />
        g.DrawRectangle(pen, New Rectangle(txtBox.Location, txtBox.Size))<br />
    End If<br />
Next<br />
Posted
Updated 2-Jan-18 20:24pm

You can add css style to all input element in your form.
Here add the below css style tag in your form
CSS
input[type=text]{
    border: 2px dotted;
}
 
Share this answer
 
Comments
Victor Palumbo 28-Dec-17 1:39am    
This is a Windows Form Application not a Web Application. Thank you though.
Yes, it is possible. Check this: Pen.DashCap Property (System.Drawing)[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900