我想做个程序,其中有一个功能是:当用户在文本框中输入数据后,只要文本框失去焦点,就会把它的内容提交供程序使用
在C#中应用哪个函数来完成??
请大家帮忙
谢谢!!!

解决方案 »

  1.   

    有一个属性可以设置,属性名只记了一部分auto* 呵呵
      

  2.   

    .cs文件:
    TextBox1.Attributes.Add("onblur","if(this.value!='')this.form.submit();");
      

  3.   

    或设置属性:
    AutoPostBack为true
      

  4.   

    private void textBox1_Enter(object sender, System.EventArgs e)
    {
        // If the TextBox contains text, change its foreground and background colors.
        if (textBox1.Text != String.Empty)
        {
            textBox1.ForeColor = Color.Red;
            textBox1.BackColor = Color.Black;
            // Move the selection pointer to the end of the text of the control.
            textBox1.Select(textBox1.Text.Length, 0);
        }
    }
    下面的代码示例使用 Leave 事件将控件重置为其以前的状态。
    private void textBox1_Leave(object sender, System.EventArgs e)
    {
        // Reset the colors and selection of the TextBox after focus is lost.
        textBox1.ForeColor = Color.Black;
        textBox1.BackColor = Color.White;
        textBox1.Select(0,0);
    }