我想设置 当窗体上文本框开始输入的时候, 文本框的背景色就变, 当文本框失去焦点的时候, 在回到原来的属性设置颜色, 如何实现???拜托各位!!!

解决方案 »

  1.   

    在 GotFocus LoseFocus 事件里面写。
      

  2.   

     private void textBox1_Enter(object sender, EventArgs e)
            {
                textBox1.BackColor = Color.Gray;
            }        private void textBox1_Leave(object sender, EventArgs e)
            {
                textBox1.BackColor = Color.White;
            }
      

  3.   

     //textBox1_Leave
                  //textBox1_Enter
                this.textBox1.textBox1_Enter += new System.EventHandler(this.textBox1_Enter);
                this.textBox1.textBox1_Leave += new System.EventHandler(this.textBox1_Leave);
    具体这两个方法是怎么定义的???
      

  4.   

    在 GotFocus LoseFocus 事件里面写。
      

  5.   

    双击直接进入下面了啊???
     private void textBox1_TextChanged(object sender, EventArgs e)
            {
              
            }
      

  6.   

    点TextBox控件,在右边的属性面板里面找到一个闪电的按钮,切换到事件。找到 GotFocus,双击。
      

  7.   

    没看到 GotFocus LoseFocus  事件啊?现在输入时候颜色改变 可以实现了 , 下面连个都可以 . 但是 当焦点离开的时候怎么变色呢??  private void textBox1_Leave(object sender, EventArgs e)
            {
                 textBox1.BackColor = Color.Cornsilk ;
            }        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
            {
                textBox1.BackColor = Color.Cornsilk;
            }