This question has already been answered:
How to make TextBox with rounded corners in WinForms? Tried by analogy as in the example with button. No errors, the corners do not round out. With other controls it turns out. What's wrong?
public class RoundTextBox : TextBox { public Color BackColor2 { get; set; } public Color TextBoxBorderColor { get; set; } public int TextBoxRoundRadius { get; set; } public Color TextBoxHighlightColor { get; set; } public Color TextBoxHighlightColor2 { get; set; } public Color TextBoxHighlightForeColor { get; set; } public Color TextBoxPressedColor { get; set; } public Color TextBoxPressedColor2 { get; set; } public Color TextBoxPressedForeColor { get; set; } private bool IsHighlighted; private bool IsPressed; public RoundTextBox() { Size = new Size(100, 40); TextBoxRoundRadius = 30; BackColor = Color.Gainsboro; BackColor2 = Color.Silver; TextBoxBorderColor = Color.Black; TextBoxHighlightColor = Color.Orange; TextBoxHighlightColor2 = Color.OrangeRed; TextBoxHighlightForeColor = Color.Black; TextBoxPressedColor = Color.Red; TextBoxPressedColor2 = Color.Maroon; TextBoxPressedForeColor = Color.White; } protected override CreateParams CreateParams { get { CreateParams createParams = base.CreateParams; createParams.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT return createParams; } } protected override void OnPaint(PaintEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.HighQuality; var foreColor = IsPressed ? TextBoxPressedForeColor : IsHighlighted ? TextBoxHighlightForeColor : ForeColor; var backColor = IsPressed ? TextBoxPressedColor : IsHighlighted ? TextBoxHighlightColor : BackColor; var backColor2 = IsPressed ? TextBoxPressedColor2 : IsHighlighted ? TextBoxHighlightColor2 : BackColor2; using (var pen = new Pen(TextBoxBorderColor, 1)) e.Graphics.DrawPath(pen, Path); using (var brush = new LinearGradientBrush(ClientRectangle, backColor, backColor2, LinearGradientMode.Vertical)) e.Graphics.FillPath(brush, Path); using (var brush = new SolidBrush(foreColor)) { var sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; var rect = ClientRectangle; rect.Inflate(-4, -4); e.Graphics.DrawString(Text, Font, brush, rect, sf); } base.OnPaint(e); } protected override void OnPaintBackground(PaintEventArgs e) { } protected override void OnMouseEnter(EventArgs e) { base.OnMouseEnter(e); IsHighlighted = true; Parent.Invalidate(Bounds, false); Invalidate(); } protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); IsHighlighted = false; IsPressed = false; Parent.Invalidate(Bounds, false); Invalidate(); } protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); Parent.Invalidate(Bounds, false); Invalidate(); IsPressed = true; } protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); Parent.Invalidate(Bounds, false); Invalidate(); IsPressed = false; } protected GraphicsPath Path { get { var rect = ClientRectangle; rect.Inflate(-1, -1); return GetRoundedRectangle(rect, TextBoxRoundRadius); } } public static GraphicsPath GetRoundedRectangle(Rectangle rect, int d) { var gp = new GraphicsPath(); gp.AddArc(rect.X, rect.Y, d, d, 180, 90); gp.AddArc(rect.X + rect.Width - d, rect.Y, d, d, 270, 90); gp.AddArc(rect.X + rect.Width - d, rect.Y + rect.Height - d, d, d, 0, 90); gp.AddArc(rect.X, rect.Y + rect.Height - d, d, d, 90, 90); gp.CloseFigure(); return gp; } } 