首页  编辑  

TextBox处理焦点颜色

Tags: /C#/界面处理/TextBox_RichEdit/   Date Created:

public Form1()

{

   InitializeComponent();

    foreach ( Control vControl in Controls)

   {

        if (vControl is TextBox )

       {

           (( TextBox )vControl) . Enter += new EventHandler (TextBox_Enter);

           (( TextBox )vControl) . Leave += new EventHandler (TextBox_Leave);

       }

   }

}

private void TextBox_Enter( object sender , EventArgs e)

{

   (( TextBox )sender) . BackColor = Color . Red;

}

private void TextBox_Leave( object sender , EventArgs e)

{

   (( TextBox )sender) . BackColor = SystemColors . Window;

}