最佳解答者
How to clear button click event during button is disabled?

問題
-
Hi,
I've a button click problem.
After I click the button, the process is
1. set enable property to false
2. create a thread to do something, and the main thread wait it until it finished (about 5~6 sec)
3. set enable property to true again
During the process, if I click the button again,
the button can't be clicked immediately, but the button click event is postponed after the button is re-enabled
Is it a bug of .net API, or there is something wrong of my procedure?
Thanks for any response2010年3月5日 上午 09:13
解答
-
Hi,
It seems that the issue does exists. If I removed the 'MessageBox.Show()', the issue would be reproduced.
I am sorry I can't help you on this point. You can go to the following website to post the issue about the Visual Studio.
https://connect.microsoft.com/VisualStudio/content/content.aspx?ContentID=14651&wa=wsignin1.0
Microsoft Online Community Support- 已標示為解答 KeFang Chen 2010年3月11日 上午 06:29
2010年3月10日 上午 01:45
所有回覆
-
Hi,
In fact that the 'click' event wouldn't be triggered if the value of enable property was set to false.
I have tested the issue in my environment and didn't find the problem.
You can create a simple solution and test it again.
private void button1_Click(object sender, EventArgs e) { this.button1.Enabled = false; Thread.Sleep(2000); MessageBox.Show("test click event"); this.button1.Enabled = true; }
Microsoft Online Community Support2010年3月8日 上午 03:15 -
Hi, KeFang
Thanks for your reply.
I tried your sample code, but the problem still exists.
I upload my code here.
http://www.badongo.com/file/21074493
enviroment: c# express (debug run), .net 3.5
os: win xp
maybe there is something wrong for my project setting or button setting?2010年3月8日 上午 03:55 -
Hi,
I am sorry that I can't download the project you mentioned.
I create a simple test project for you. You can download it and test it again.
http://files.cnblogs.com/wuwei_chen/ButtonEnableDemo.rar
My environment:Windows7+Visual Studio 2008
Or you can test it with the other computer
Microsoft Online Community Support2010年3月8日 上午 06:09 -
Hi,
It seems that the issue does exists. If I removed the 'MessageBox.Show()', the issue would be reproduced.
I am sorry I can't help you on this point. You can go to the following website to post the issue about the Visual Studio.
https://connect.microsoft.com/VisualStudio/content/content.aspx?ContentID=14651&wa=wsignin1.0
Microsoft Online Community Support- 已標示為解答 KeFang Chen 2010年3月11日 上午 06:29
2010年3月10日 上午 01:45