Hi,
I''m using the celldoubleclick event handler to perform a column/row collaps/Expand function and the cellclick event handler to run code for setting the propertygrid. However, when I perform a double click to collaps the column I get both a cellclick and a celldoubleclick events raised. This degrades the performance of the collaps/expand feature because it runs unneccessary through the code in the cellclick eventhandler before it runs the code in the celldoubleclick eventhandler.
How can I prevent this from happening?
Best Regards
/Tommy
AD
Administrator
Syncfusion Team
January 26, 2004 02:32 PM UTC
The problem, of course, is the grid does not know if the first click is just a singleclick or is part of a double click.
One way around this is to enable a timer in the singleclick event and set it for SystemInformation.DoubleClickTime. If the timer event fires before the doubleclick event is hit, then you know the click really was a single click.
So, move the code you currently have in CellClick to the timer event. In CellClick, enable the timer. In the timer event, disable the timer and do your code. Also, in the doubleclick event, disable the timer before doing your work there.
TN
Tommy Norman
January 27, 2004 06:26 AM UTC
Thanks clay it works!
How do I pass the (object sender, GridCellClickEventArgs e) from the cellclick event to the timer event handler in the best way?
/Tommy
>The problem, of course, is the grid does not know if the first click is just a singleclick or is part of a double click.
>
>One way around this is to enable a timer in the singleclick event and set it for SystemInformation.DoubleClickTime. If the timer event fires before the doubleclick event is hit, then you know the click really was a single click.
>
>So, move the code you currently have in CellClick to the timer event. In CellClick, enable the timer. In the timer event, disable the timer and do your code. Also, in the doubleclick event, disable the timer before doing your work there.
AD
Administrator
Syncfusion Team
January 27, 2004 08:59 AM UTC
Probably the most staight-forward way would be to just add a private member to your class (if the timer evenhandler and the cellclick event handler are in the same class).
If you need to access things from different classes you could use a Static (Shared in VB) member.
Another option, depending upon what you need (like grid row and column index), you might be able to calcualte that if you know the grid.
TN
Tommy Norman
January 27, 2004 09:26 AM UTC
Hi again clay
I needed to know the current row & column index inside the timer event handler but I could get it out from the grid so know it works but by using a timer like this I just move the performance problem from the double click to the single click event handler because the code waits till the double click timer ticks.
Any other ideas?
/Tommy
AD
Administrator
Syncfusion Team
January 27, 2004 12:30 PM UTC
No I don''t.
I do not know how to distinguish a single click from the first click of a double click unless you wait a moment to see if there is another click.
I thought the efficiency problem had to do with avoiding the code in the single click event by making sure you only executed if it was in fact a single click. This timer will make sure you only do the single click code if the click was in fact a single click.
TN
Tommy Norman
January 27, 2004 01:23 PM UTC
Yes you are right, the efficiency problem is solved for the double click event, but the code I want to execute when I make "just" a single click is now delayed with the DoubleClickTime and this doesn''t give that instant respons I''m looking for.
I skipped the timer and went back to the original solution and have now tuned the code in the cellclick event handler till it''s limits.
The respons time for both single and double click
looks a bit better and I hope it will be accepted by the users.
Thanks Clay for your support
Best Regards
Tommy