给label,textbox等控件加边框的方法
一:
1.拉入一个panel控件,
设置backcolor 为需要的边框颜色,
设置padding为(1,1,1,1)边框的宽度
2.添加textbox控件在panel里,并设置dock属性为fill
就可以了
二:写paint事件
private void panel1_Paint(object sender, PaintEventArgs e)
{
ControlPaint.DrawBorder(e.Graphics, panel1.ClientRectangle,
Color.White, 1, ButtonBorderStyle.Solid, //左边
Color.White, 1, ButtonBorderStyle.Solid, //上边
Color.DimGray, 1, ButtonBorderStyle.Solid, //右边
Color.DimGray, 1, ButtonBorderStyle.Solid);//底边
}