C#,textbox怎么把边框设置颜色,把四个角改成圆角?
textbox 系统控件,直接改肯定是没办法的,只能自己重写控件,继承TextBox
而且圆角应该只能完全重写控件
给你个改边框颜色的代码
public class MyTextBox : TextBox
{
public MyTextBox()
{
this.BorderStyle = BorderStyle.FixedSingle;
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == 0xf || m.Msg == 0x14 || m.Msg == 0x85)
{
if (this.BorderStyle == BorderStyle.FixedSingle)
{
using (Graphics g = Graphics.FromHwnd(this.Handle))
{
using (Pen pen = new Pen(Color.Red))
{
g.DrawRectangle(pen, 0, 0, this.Width - 1, this.Height - 1);
}
}
}
}
}
}