Command button Click event firing twice when user double click it.


Author
Message
Edhy Rijo
E
StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi guys,

I am having a situation where some users are double clicking a command button and its Click() event is being fired twice, is there a way to prevent this?

I have done some research in Google but could not find an easy solution, other than creating a timer to handle the click.

Thanks!

Edhy Rijo

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Edhy.

Would disable the button once it enters the Click event work? And then Enable it back once you finish everything you want to do inside it?
Edhy Rijo
E
StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Ivan,

Thanks for the prompt response.  Yes that does the trick even though it is weird that a double click action would be registered twice.  This mean that now I would have to re-test all my buttons or create a subclass to do the enable/disable trick.

Is this also happening to you?

Edhy Rijo

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Nope, never thought of it. But it does make sense it runs twice, since the user clicked the thing twice.

I think we could put a message "Can you please give the application some time to do its job?!" to the user, and of course, use the Localization and Messaging Editor to create a key to this message, so we do it in all languages possible. BigGrin
Edhy Rijo
E
StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Well, you should have seen my face when I got the call from the user reporting that my process was running twice Crying

At least I have only get one call on this specific process, so for now fixing this button will be enough.  Hmmm, never got that complaint using Visual FoxPro w00t but did get others Satisfied

Edhy Rijo

Russell Scott Brown
Russell Scott Brown
StrataFrame User (246 reputation)StrataFrame User (246 reputation)StrataFrame User (246 reputation)StrataFrame User (246 reputation)StrataFrame User (246 reputation)StrataFrame User (246 reputation)StrataFrame User (246 reputation)StrataFrame User (246 reputation)StrataFrame User (246 reputation)
Group: Forum Members
Posts: 124, Visits: 597
Hello Edhy. 

I know if FoxPro I often run into problems with people, especially older ones, double-clicking on command buttons like crazy for some reason.  Also have the issue where they do 2 single-clicks instead of 1 double-click because they are mouse challenged.

Anyway, this workaround is good to know.  Thanks

Russ Brown (Using C#2010/SQL Server 2008)
Edhy Rijo
E
StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Russell Scott Brown (11/19/2010)
I know if FoxPro I often run into problems with people, especially older ones, double-clicking on command buttons like crazy for some reason.  Also have the issue where they do 2 single-clicks instead of 1 double-click because they are mouse challenged.

Hi Russell,

That is good to know, but I did reproduced the issue with a very fast double click and was surprised to see my process running twice.

Edhy Rijo

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Now that I gave it some more thinking, I do have some buttons that start long processing that I disable as soon as they get clicked... and not only them, many of the form controls that are waiting for a click, so the user won't get a chance to mess it up.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (2.7K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Here's some info on how the click/double-click events play together: Control.DoubleClick Event.  This supports the advice to disable further clicks until the process is completed.
Edhy Rijo
E
StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Thanks Greg, very good information about those events.

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search