private void btnN1_Click(object sender, EventArgs e)
{
   this.txt.Text += btnN1.Text;
}给每个数字按钮写上类似的代码

解决方案 »

  1.   

    窗体里定义
     private void ShowNum(object sender, EventArgs e)
    {
        textBox1.Text = ((Button)sender).Text;
    }
    designer.cs里修改
    (X为0-9)
    this.buttonX.Click += new System.EventHandler(this.ShowNum);
      

  2.   


            TextBox _TextBox = null;
            public TextBox TextBox
            {
                get { return _TextBox; }
                set
                {
                    if (_TextBox != value)
                    {
                        _TextBox = value;
                    }
                }
            }        private void btnOne_Click(object sender, EventArgs e)
            {
                if (this.TextBox != null)
                {
                    this.TextBox.Text += btnOne.Text;
                    this.TextBox.Focus();
                    this.TextBox.SelectionStart=this.TextBox.Text.Length;
                }
            } private void txtBox(object sender, EventArgs e)
    {
        textBox.Text = ((txtBox)sender).Text;
    }
      

  3.   

    private void txtBox_GetFocus(object sender, EventArgs e)
    {
        textBox.Text = ((txtBox)sender).Text;
    }少打了必个字
      

  4.   

    楼上的好像都不太对吧 单个按钮事件太多的话 不行 再说每次按按钮,text应该追加才对,应该用按钮继承事件和数组追加来做吧