473,379 Members | 1,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

DateTimePicker DropDown

Is there a way to programatically tell the DateTimePicker control to drop down?

My form needs the date to be selected, and whenever it is "rolled up," it is
less obvious for my operators to see.
Jul 24 '08 #1
3 6000
On Jul 25, 12:48*am, jp2msft <jp2m...@discussions.microsoft.com>
wrote:
Is there a way to programatically tell the DateTimePicker control to dropdown?

My form needs the date to be selected, and whenever it is "rolled up," itis
less obvious for my operators to see.
try the following code

[DllImport("user32.dll")]
private static extern bool PostMessage(
IntPtr hWnd, // handle to destination window
Int32 msg, // message
Int32 wParam, // first message parameter
Int32 lParam // second message parameter
);

const Int32 WM_LBUTTONDOWN = 0x0201;

private void dateTimePicker1_MouseEnter(object sender, EventArgs e)
{
Int32 x = dateTimePicker1.Width - 10;
Int32 y = dateTimePicker1.Height / 2;
Int32 lParam = x + y * 0x00010000;

PostMessage(dateTimePicker1.Handle, WM_LBUTTONDOWN, 1,
lParam);
}

The above code is in MouseEnter event, If you want datetime picker
dropped down by default, try putting the code in Form_Load insted of
MouseEnter.

Hope this will help.

-Cnu
Jul 25 '08 #2
On Jul 25, 12:48*am, jp2msft <jp2m...@discussions.microsoft.com>
wrote:
Is there a way to programatically tell the DateTimePicker control to dropdown?

My form needs the date to be selected, and whenever it is "rolled up," itis
less obvious for my operators to see.
[DllImport("user32.dll")]
private static extern bool PostMessage(
IntPtr hWnd, Int32
msg, Int32 wParam, Int32
lParam
);

const Int32 WM_LBUTTONDOWN = 0x0201;

private void Form1_Load(object sender, EventArgs e)
{
Int32 x = dateTimePicker1.Width - 10;
Int32 y = dateTimePicker1.Height / 2;
Int32 lParam = x + y * 0x00010000;

PostMessage(dateTimePicker1.Handle, WM_LBUTTONDOWN, 1,
lParam);
}

Hope this will do.
-Cnu
Jul 25 '08 #3
Nice API Call there, Duggi. Thanks!

Do you know off hand which parameter below made my left mouse button hot,
though?

After sending the WM_LBUTTONDOWN message to the system, every place I moved
my mouse over on the Calendar caused something to happen. Most noticably,
whenever my mouse hovered above the Month Selectors, the months changed -
same with the year.

"Duggi" wrote:
[DllImport("user32.dll")]
private static extern bool PostMessage(IntPtr hWnd, Int32 msg,
Int32 wParam, Int32 lParam);
const Int32 WM_LBUTTONDOWN = 0x0201;
private void Form1_Load(object sender, EventArgs e) {
Int32 x = dateTimePicker1.Width - 10;
Int32 y = dateTimePicker1.Height / 2;
Int32 lParam = x + y * 0x00010000;
PostMessage(dateTimePicker1.Handle, WM_LBUTTONDOWN, 1, lParam);
}

Hope this will do.
-Cnu
Jul 25 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Shravan | last post by:
Hi , I have a datetimepicker in my application. I am dropping it down (showing calendar control). When the drop down window (calendar control) is visible how can I programmatically closeup the...
3
by: touf | last post by:
Hi, I've a dateTimePicker control with a dropDown list to select. I like to give the possibility to type the date manually (using the keyboard, without selection) without to change the dropDown ...
0
by: Barkster | last post by:
Is it possible to have the updown buttons and the dropdown menu for the date? Also, below I trying to get the date and time in the format below, which works in the datetimepicker but when...
0
by: KC | last post by:
How can you capture an event from the dropdown calendar in a DateTimePicker? I want the date the user picks to be added to a listbox, but the only way I can think to do that now it to check the...
4
by: Jordi Rico | last post by:
Hi, I'd like to know if there's any way to force a DateTimePicker to dropdown, something like PerformClick() in a button... I'd like to force this dropdown from the click event in other button...
1
by: mfleet1973 | last post by:
Hi. I'm using vb.net 2003. I'm trying to find a way to detect when the calendar "pops up". For example, when the user clicks on the button to display the calendar, I need to know that this...
2
by: Claes Wedin | last post by:
My customer needs a DateTimePicker in VS2005 C# that can show emty date values (blank/space/null). I need a control that: 1. Can show a blank value 2. Detete a date when hitting the delete...
2
by: Michel Vanderbeke | last post by:
Hello, Is it possible to open a DateTimePicker control when it gets the focus? Thanks and greetings, Michel
1
by: Dave Anson | last post by:
How can I change the color of the dropdown arrow on DateTimePicker? I have used the ToolStripRender class to change the back color/gradient of the ToolStrip, and DrawMode for some other controls....
4
by: jehugaleahsa | last post by:
Hello: We were hoping to allow users to have DateTimePicker value null so that a unused date is stored on a Database. Does the control support this? I am pretty sure it doesn't. How would you...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.