1,用panel置于文本框背后,并让panel的size四个方向都比文本框多一个像素(或者你希望的边框宽度)
2,将panel的背景色设为希望的边框颜色
this.panel1.BackColor = System.Drawing.Color.Red;
3,比如可以加MouseOver 和 MouseLeave 事件
this.textBox1.MouseHover += \
new System.EventHandler(this.textBox1_MouseHover);
this.textBox1.MouseLeave += \
new System.EventHandler(this.textBox1_MouseLeave);
4,然后看MouseOver 和 MouseLeave 事件的处理
private void textBox1_MouseHover(object sender, EventArgs e)
{
this.panel1.BackColor = System.Drawing.Color.Red;
}
private void textBox1_MouseLeave(object sender, EventArgs e)
{
this.panel1.BackColor = System.Drawing.Color.Blue;
}
利用JAVASCRPT修改CSS控制即可,如下
你是在问CSS??? style="border:1px solid red"
border-color:#000;
border-size:3px;
制定一个MouseEnter的鼠标事件,当鼠标移入文本框,则Textbox的属性BackColor=the color you want
应该是winform 重写TextBox 很简单的