VS 2005 -
I want to add an event handler for a datetimecontrol using the event ENTER.
When the datetime is entered I want it set to todays date
I have tried using the object.value but it does not seem to work.
Can anyone correct the for me - thanks
void hnOnEnterDT(object sender, EventArgs e)
{
/* date picker - handler for (Enter)
* Set the control to the current date
*/
= System.DateTime.Today;
}

eventhandler for datetime control
minority80
I agree it would work if I assigned a name (datepicker1)
but I have 3 datepickers and I want to use the event for any or all three.
otherwise I may as well put the action in the named datepickers_enter and not use a handler.
Lee John
Then try:
void onEnterDateTime (object sender, EventArgs e) {
((DateTimePicker) sender).Value = DateTime.Now;
}
HTH
--mc
p.b.a
Setting the Value property does work. If your control is named dateTimePicker1:
void dateTimePicker1_Enter (object sender, EventArgs e) {
dateTimePicker1.Value = DateTime.Now; // System.DateTime.Today also works, but...
}
At this point a possible explanation is that the event is not bound correctly.
HTH
--mc
Tyrael117
perfect - thanks
Rahul Garg
well you can implement the enter event as you probably have done then in this event you want to set todays date and to do this, as you have also stated, you should use the Value property but what happens when you say it does not seem to work