日期:2014-05-17  浏览次数:20846 次

textBox1的操作
键盘操作textBox1,无论是退格键backspace,还是删除键delete,

操作之后 textBox1.Text = "1",

该如何实现呢?谢谢

------解决方案--------------------
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)8 
------解决方案--------------------
 e.KeyChar == (char)46)
            {
                this.textBox1.Text = "1";
            }
        }

------解决方案--------------------

  public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            textBox1.TextChanged+=new EventHandler(textBox1_TextChanged);
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.Text != "1")
            {
                textBox1.Text = "1";
            }
        }
    }

------解决方案--------------------
textBox1_Changed
{
    if (textBox1.Text == "") textBox1.Text == "1";