Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I need a textbox whose bottom border needs to be two pixel and color blue? How to do it?
Posted

1 solution

By overriding of the method OnPaint in the derived class. If you need more room for this declaration, you would also need to adjust the client size using y overriding the method SetClientSizeCore.

Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.onpaint.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.setclientsizecore.aspx[^].

Instead of overriding of the method OnPaint you can also handle the event Paint, but it makes not much sense if you have to create a derived class anyway:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.paint.aspx[^].

When rendering, don't repeat a common mistake: don't create an instance of the class System.Drawing.Graphics, instead, use the one passed in the event argument parameter.

—SA
 
Share this answer
 
v3
Comments
brijgogogo 14-Nov-12 6:32am    
How to create the border ?
Sergey Alexandrovich Kryukov 14-Nov-12 11:25am    
Graphics.DrawRectangle, of course...
--SA

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