scimili.blogg.se

Devexpress datecontrol mousedown
Devexpress datecontrol mousedown















Private void dateTimePicker1_MouseDown( object sender, MouseEventArgs e) If you attach to the MouseDown or MouseUp event you can easily add one line to call the extension on you control and just like that, your calendar will pop-up: using

Devexpress datecontrol mousedown code#

The EventSuppressor is something I picked up on this discussion to stop any other events from firing and also prevent infinite loops calling your mouse events over and over (the code for this in included in the sample code). The extra mouse click event info requirement is so that we can detect where the click happened and ignore it if it was actually on the calendar button (because otherwise it clicks again hiding the calendar – DOH!). NET Compact Framework you need to import coredll instead for the P/Invoke for SendMessage so the compiler directive is there to support that. SendMessage(picker.Handle, WM_LBUTTONUP, 1, lParam) SendMessage(picker.Handle, WM_LBUTTONDOWN, 1, lParam) Ignore if the calendar button was clicked if (clickEvent.X < picker.Width - 35) Var suppressor = new EventSuppressor(picker)

devexpress datecontrol mousedown

Remove any existing event to prevent an infinite loop. Public static void ShowCalendar( this DateTimePicker picker,

devexpress datecontrol mousedown

Private const int WM_LBUTTONDOWN = 0x0201 #endif static extern int SendMessage(IntPtr hWnd, uint uMsg, Public static class DateTimePickerExtensions So we can use some native calls as well as basic math to find a good position to click it and send the message like so: using System We want to make a click happen here (in the red box): So I made an extension method with some parts borrowed which add an additional method on the control. By forcing this extra click in the right area it's as if you just clicked the button yourself. I found a way to get this to work by sending a "mouse button down/up" message to the control in the area where the regular display button is. What if you wanted the calendar to pop-up when simply clicking on any area of a control? You would expect the control to have a method to easily do this but when you notice there isn't even a public Click event things start looking bleak.

devexpress datecontrol mousedown

Something that’s common-place on the web is clicking a text box to pop-up a calendar.















Devexpress datecontrol mousedown