改變文本框的背景色我有我的表格如下代碼:入境時
private void txt1_Enter(object sender, EventArgs e)
{
txt1.SelectAll();
txt1.BackColor = Color.LightBlue;
}
private void txt2_Enter(object sender, EventArgs e)
{
txt2.SelectAll();
txt2.BackColor = Color.LightBlue;
}
private void txt1_Leave(object sender, EventArgs e)
{
txtThermalConductivity.BackColor = Color.White;
}
private void txt2_Leave(object sender, EventArgs e)
{
txtThermalConductivity.BackColor = Color.White;
}
有我的窗體上的另一個20個文本框,我想這樣做的一樣。是否有可能將所有進入事件和所有離開事件組合起來,因此我總共有兩個事件而不是44個單獨事件?
非常感謝! 'SelectAll'用於在輸入每個文本框時選擇所有文本,從而更快地更改輸入。 – Harry 2013-04-07 23:16:07
@哈利噢好吧:) – 2013-04-07 23:16:31