(Syncfusion v. 9.103.0.20 in a .NET 3.5 project)
I'm using the MonthCalendarAdv control, and am trying to respond to the user doubleclicking on a date.
I've got it working, but my way seems like a hack. (Sample code below)
Do you have a better way?
---
I've hooked the monthCalendarAdv1's double-click event. It fires whenever any of the MonthCalendarAdv is double-clicked: header, change month buttons, today button, etc.
The only way I found to figure out if a date was double-clicked was to use the mouse position and see if the child_control clicked was a GridControl. That seems like a hack - and if Syncfusion ever changes internal implementation of MonthCalendarAdv, it would break my code.
Is there a way to know this info directly rather than depending on this mouse-position child-control hack?
// in _DoubleClick event
private void monthCalendarAdv1_DoubleClick(
object sender,
EventArgs e)
{
// Get the child control at the mouse location
Control control =
monthCalendarAdv1.
GetChildAtPoint
(monthCalendarAdv1.
PointToClient(
Control.MousePosition));
if (control.GetType().Name == "GridControl")
{
// Day was doubleclicked, handle it
}
else
{
// some other part of monthCalendarAdv control clicked
}
}
Thanks,
Joel
JM
Joel McIntyre
May 9, 2011 07:24 PM UTC
And with further testing my hack above, it helps but is far short of perfect. Better behaved hack is to start with the above, but set a 'bool doubleclicked;' flag to true on "doubleclick in grid" and false in a monthCalendarAdv1_Click handler.
Then, in all DateSelected handler calls, trigger the "date was doubleclicked" if the doubleclicked flag is true.
--
I can almost get away with "Doubleclick call followed by DateSelected call" for all cases, but then doubleclicking the Today button also triggers "doubleclick on day" code.
--
So, if there is a non-hack way to accomplish this, I'm very interested!
JJ
Jeraldes J
Syncfusion Team
May 13, 2011 04:47 PM UTC
Hi Joel,
Thanks for your interest in using Syncfusion Products.
We have modified the condition checking in your code snippet. which would provide you the better solution.
Please refert the same from the following code snippet.
[Code Snippet]
Control control = monthCalendarAdv1.GetChildAtPoint(monthCalendarAdv1.PointToClient(Control.MousePosition));
if (control is GridControl)//.GetType().Name == "GridControl")
{
// Day was doubleclicked, handle it
MessageBox.Show("Monthcalender Double Clicked");
}
else
{
// some other part of monthCalendarAdv control clicked
}
Please let us know if you have any concern.
Regards,
J Jerakdes
JJ
Jeraldes J
Syncfusion Team
May 13, 2011 04:47 PM UTC
Hi Joel,
Thanks for your interest in using Syncfusion Products.
We have modified the condition checking in your code snippet. which would provide you the better solution.
Please refert the same from the following code snippet.
[Code Snippet]
Control control = monthCalendarAdv1.GetChildAtPoint(monthCalendarAdv1.PointToClient(Control.MousePosition));
if (control is GridControl)//.GetType().Name == "GridControl")
{
// Day was doubleclicked, handle it
MessageBox.Show("Monthcalender Double Clicked");
}
else
{
// some other part of monthCalendarAdv control clicked
}
Please let us know if you have any concern.
Regards,
J Jeraldes
JM
Joel McIntyre
May 13, 2011 08:40 PM UTC
Thanks, if this is indeed the best approach you've got, then I'll consider it good enough for now.
(On "is GridControl" vs. "Name = "GridControl"", I wasn't sure if hard binding to a GridControl type at compile time made the code more fragile since I'm already tying to internal behavior. But either way works for current implementation.)
And please do consider some sort of "Date Activated" event when a day is double-clicked (or enter key, or similar common "activation") as a future release feature request!
Many Thanks,
Joel