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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

changing border color of Textbox control

Thread ID:





13982 May 14,2004 05:14 PM UTC May 18,2004 04:16 PM UTC WinForms 1
Tags: FAQ
Asked On May 14, 2004 05:14 PM UTC

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

Administrator [Syncfusion]
Replied On May 18, 2004 04:16 PM UTC

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.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon