Single clicks on web listbox firing twice

I have a web listbox which has a cellclick even that does something when the user clicks on a row (based on the row selected). The problem is that I have an overzealous user who cant get their head round single or double click so they double click on everything in a listbox. The problem is that when they double click the cellclick event fires twice and it is cause the stuff that is going on in the event to happen twice and screwing the rest of my code.

I thought I could put a check using a page boolean property to check if the cellclick event had occurred and if is has then dont continue and then at the end of the event I set the boolean back to false but it does seem to help and I am not sure if it is because the event is happening so quick that it finishes before the user clicks for the second time or if the event hasnt finished so the property has been set before the second instance of it starts.

So I thought I would create a double click event handler that puts up a message say “Just click once!” but the message is displayed but the cellclick still fires twice.

How can I resolve this?

How about a couple of properties lastClickCell as Pair and lastClickMS as double? When you get a click, compare to the last clicked cell, and use Microseconds / 1000 to determine the time between events in milliseconds. If it’s too soon on the same cell, skip out.

Hi Brad, that works but how can I create a very of the listbox that has this check built into the CellClick event handler so that if the event fires within half a second of the previous click then it aborts the CellClick event? I have never created a version of an object before.

Subclass ListBox – call it MyListBox. Add the properties, handlers, declare new Event Handlers to present the events you implemented. Take a look at WEListBox in Web Essentials, It might even be easier to add this stuff to your local copy of that.

Thanks Brad, I will look at adding it to the WEListbox as I am using this in the place where I am getting the issue. Thanks again.

You suggestion worked by using the Millisecond and if it is over 800 then I allow the click to occur otherwise I ignore it.

I do think that this is a bug because if you have a cellclick even and a double click event handler then when you double click on the listbox row the double click event fires once and the cellclick event fires twice. In a desktop app this isnt the case and their may well be times in a web app when you would like to do something on a single click and something different on a double click. Also why doesnt the double click event pass back the row / column that was clicked like the cellclick event?