We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

changing border color of Textbox control

Hello Everyone, I am trying to create a custom textbox control and set the border color to green. I have created a new class and defined the following: public class MyTextBox : TextBox { public Color m_Color; public MyTextBox() { } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); int borderWidth = 1; ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, this.hitesh, borderWidth, ButtonBorderStyle.Solid, this.hitesh, borderWidth, ButtonBorderStyle.Solid, this.hitesh, borderWidth, ButtonBorderStyle.Solid, this.hitesh, borderWidth, ButtonBorderStyle.Solid); } After doing this, I am creating textbox control programatically on my form. However, I am not able to change the border color. If I try to create a button instead, everything works fine. Can somebody please suggest me what am I doing wrong here? Thanking you all, Hitesh

1 Reply

AD Administrator Syncfusion Team May 18, 2004 12:16 PM

In short, the problem is that the border should be draw in the Non-Client area. Start by listening to the WM_NCPAINT in the WndProc override and go from there. You should look up some samples on how to paint in the NC area. -Praveen Syncufsion.

Loader.
Live Chat Icon For mobile
Up arrow icon