TextBox的Leave事件里 编写了代码。
在从TextBox输入完毕。直接点一个button。第一次没有作用。再继续点的时候才有作用-执行了button_Click;好像TextBox的Leave事件 把 button的第一次button_Click事件取消了。
如何解决一次一按
button时候就能有作用!!!!

解决方案 »

  1.   

    还是不行啊。
    第一次点button时还是没反应。。
      

  2.   

    我试过可以阿
    是不是 textBox1_Leave的代码 异常 引起的using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void textBox1_Leave(object sender, EventArgs e)
            {
                textBox1.Text = textBox1.Text+"textBox1_Leave";
            }        private void button1_Click(object sender, EventArgs e)
            {
                MessageBox.Show(textBox1.Text);
            }
        }
    }
      

  3.   

    TextBox怎么会取消Button的事件呢?
    贴代码吧
      

  4.   

    我也试了。。我 的 这里代码是 这样   public partial class Form1 : Form
        {
            [DllImport("User32.dll")]
            private static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo);
            public Form1()
            {
                InitializeComponent();
                     }        private void textBox1_Leave(object sender, EventArgs e)
            {
                keybd_event(0x11, 0x45, 0x1 | 0x2, 0);
            }        private void button1_Click(object sender, EventArgs e)
            {
                MessageBox.Show("asdfasdf"); 
            }估计是 keybd_event 导致的。
      

  5.   

    keybd_event 事件 不是不能用。
    会将第一次 button1_Click 取消掉
      

  6.   

    SendKeys() 一样 有这个问题。。我其实就想 在一个dataGridView。
    (程序按Ctrl键)实现自动点选多行。
    在选择结束后 dataGridView失去焦点 (程序放开 Ctrl)(要不然Ctrl一直按着,影响其他)
      

  7.   

     淡然不行了,由不是Button-Click 事件 ,当然不执行了
      

  8.   


           private void button2_Click(object sender, EventArgs e)
            {
                MessageBox.Show("OK");
            }        private void textBox1_Leave(object sender, EventArgs e)
            {
                this.Text = "kk";
            }
    我这样做第一次button2_Click是不会取消的,4楼的说得好,要是我,也会试做调试。
      

  9.   

    keybd_event(0x11, 0x45, 0x1 | 0x2, 0); 
    你们放到textBox1_Leave里试试。。
    放this.Text = "kk";
    没关系的。。可以一点就出的。但放keybd_event(0x11, 0x45, 0x1 | 0x2, 0); 
    就不行了
      

  10.   

    实在看不懂你的代码:
    keybd_event(0x11, 0x45, 0x1 | 0x2, 0); 
    所以也不好调试
      

  11.   

    textbox的Leave事件怎么写啊,谁能贴出html和cs代码,我没有写过这类的东西