我的程序里 TXTBOX设置了自动转换成大写
this.t_input.Text = this.t_input.Text.ToUpper();我另外增加了一个退出按纽,可以使用F2键作为快捷键
            if (e.KeyData == Keys.F2)
            {
                //t_input.LostFocus();
                b_exit_Click(b_exit,EventArgs.Empty);              
            }
但按下F2后,程序出现错误Object DisposedException
请确保在试图使用某个资源之前尚未将其释放

解决方案 »

  1.   

    看看这个帖子有没有帮助http://topic.csdn.net/u/20090305/20/c1e8c6fa-784a-4ab1-82a3-48926af8767e.html
      

  2.   

        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void textBox1_KeyDown(object sender, KeyEventArgs e)
            {
                this.textBox1.Text = this.textBox1.Text.ToUpper();
                this.textBox1.SelectionStart = this.textBox1.Text.Length;
                this.textBox1.SelectionLength = 0;
            }        private void button1_Click(object sender, EventArgs e)
            {
                Application.Exit();
            }        private void Form1_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyData == Keys.F2)
                {                button1_Click(button1, EventArgs.Empty);
                }
            }
      

  3.   

     button1_Click(button1, EventArgs.Empty);
    这个改成   button1_Click(null, null);
     试试
      

  4.   

    设置 KeyPreview 为 true ,未出现异常。