Winform实现圆角TextBox
在WEB或WPF里很好实现,WINFORM下好像要重绘控件吧。
具体的实现代码,哪位能提供一下呢,谢谢了。
------解决方案--------------------
private void Form1_Load(object sender, EventArgs e)
       {
           this.textBox1.Region = new Region(GetRoundRectPath(new RectangleF(0, 0, this.textBox1.Width, this.textBox1.Height), 10f));
       }
       //适合调整参数radius...
       public GraphicsPath GetRoundRectPath(RectangleF rect, float radius)
       {
           return GetRoundRectPath(rect.X, rect.Y, rect.Width, rect.Height, radius);
       }
       public GraphicsPath GetRoundRectPath(float X, float Y, float width, float height, float radius)
       {
           GraphicsPath path = new GraphicsPath();
           path.AddLine(X + radius, Y, (X + width) - (radius * 2f), Y);
           path.AddArc((X + width) - (radius * 2f), Y, radius * 2f, radius * 2f, 270f, 90f);
           path.AddLine((float)(X + width), (float)(Y + radius), (float)(X + width), (float)((Y + height) - (radius * 2f)));
           path.AddArc((float)((X + width) - (radius * 2f)), (float)((Y + height) - (radius * 2f)), (float)(radius * 2f), (float)(radius * 2f), 0f, 90f);
           path.AddLine((float)((X + width) - (radius * 2f)), (float)(Y + height), (float)(X + radius), (float)(Y + height));
           path.AddArc(X, (Y + height) - (radius * 2f), radius * 2f, radius * 2f, 90f, 90f);
           path.AddLine(X, (Y + height) - (radius * 2f), X, Y + radius);
           path.AddArc(X, Y, radius * 2f, radius * 2f, 180f, 90f);
           path.CloseFigure();
           return path;
       }
------解决方案--------------------