Click here to Skip to main content
15,918,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys I have a date time picker control on my form, and what i want is that when the user clicks on the text field of that date time picker the calendar should open.

Is this possible? If so, how can i accomplish this?

Thanks.

Its a WinForm.
Posted
Updated 21-Dec-11 21:33pm
v2

 
Share this answer
 
Comments
Wendelius 22-Dec-11 15:05pm    
Didn't notice this solution before. I think that the article is undervalued, it's not totally excellent but IMO worth lots of more than 2.88.

I think this was a good link. 5'd
First on form load (or in constructor) wire for example GotFocus event
C#
dateTimePicker1.GotFocus += new EventHandler(dateTimePicker1_GotFocus);


And then in the handler
C#
void dateTimePicker1_GotFocus(object sender, EventArgs e) {
   System.Windows.Forms.SendKeys.Send("%{DOWN}");
}
 
Share this answer
 
v2
Comments
thatraja 22-Dec-11 12:58pm    
I didn't try this but possible case, 5! Its been long time I have worked in winforms
Wendelius 22-Dec-11 14:52pm    
Thanks, it's been some time for me also so I tested it before posting :)
thatraja 22-Dec-11 15:00pm    
I need to install VS that's why I couldn't.
BTW I found that article in CP but it looks like poor one(not sure just an assumption based on rating) but fine for OP's requirement.
Yes, it is possible using AJAX Control Toolkit. refer this article for implementation:

DatePicker in ASP.NET 2.0 and AJAX Control Toolkit[^]

Or you can use this :

DateTimePicker Web Control[^]
hope it helps :)
 
Share this answer
 
v2
Comments
Member 8102934 22-Dec-11 3:30am    
Hi thanks for the response, but its not an asp.net page its a WindowsForm.
Uday P.Singh 22-Dec-11 9:55am    
you didn't mentioned it earlier
create another form
add calender on this form

on your parent form's textbox focus event
show calender form
onslecteddate close calender form and pass value to your
text box
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900