TextBox的Leave事件里 编写了代码。
在从TextBox输入完毕。直接点一个button。第一次没有作用。再继续点的时候才有作用-执行了button_Click;好像TextBox的Leave事件 把 button的第一次button_Click事件取消了。
如何解决一次一按
button时候就能有作用!!!!
在从TextBox输入完毕。直接点一个button。第一次没有作用。再继续点的时候才有作用-执行了button_Click;好像TextBox的Leave事件 把 button的第一次button_Click事件取消了。
如何解决一次一按
button时候就能有作用!!!!
第一次点button时还是没反应。。
是不是 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);
}
}
}
贴代码吧
{
[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 导致的。
会将第一次 button1_Click 取消掉
(程序按Ctrl键)实现自动点选多行。
在选择结束后 dataGridView失去焦点 (程序放开 Ctrl)(要不然Ctrl一直按着,影响其他)
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楼的说得好,要是我,也会试做调试。
你们放到textBox1_Leave里试试。。
放this.Text = "kk";
没关系的。。可以一点就出的。但放keybd_event(0x11, 0x45, 0x1 | 0x2, 0);
就不行了
keybd_event(0x11, 0x45, 0x1 | 0x2, 0);
所以也不好调试