Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / December 2005

Tip: Looking for answers? Try searching our database.

The code to change dateTimePicker control not working.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alpha - 29 Dec 2005 20:37 GMT
I have a DateTimePicker control that originally displays "1/1/1900" on
screen.  I want to change it to current date when a user clicks on it.  I use
the follow code but nothing is happening.  Can someone tell me what I'm doing
wrong?
Thanks, Alpha

private void dtpLastOdoDate_Click(object sender, System.EventArgs e)
{
    dtpLastOdoDate.Value = DateTime.Today.Date;
}
John - 30 Dec 2005 02:19 GMT
dtpLastOdoDate.Update();    // ??

> I have a DateTimePicker control that originally displays "1/1/1900" on
> screen.  I want to change it to current date when a user clicks on it.  I use
[quoted text clipped - 6 lines]
>     dtpLastOdoDate.Value = DateTime.Today.Date;
> }
Alpha - 30 Dec 2005 05:11 GMT
Thanks John.  I added the code you suggested
dtpLastOdoDate.Update();
but it still not working.  

> dtpLastOdoDate.Update();    // ??
>
[quoted text clipped - 8 lines]
> >     dtpLastOdoDate.Value = DateTime.Today.Date;
> > }
chandra - 30 Dec 2005 15:06 GMT
i doubt we have a click event for the datetimepicker control.

instead to achieve ur thing. write the code in Enter event handler of
the datetimepicker control.
Alpha - 30 Dec 2005 18:53 GMT
There is a Click event but it does nothing with the code I put in there.  The
Enter event is working out just great.  Thank you Chandra.

> i doubt we have a click event for the datetimepicker control.
>
> instead to achieve ur thing. write the code in Enter event handler of
> the datetimepicker control.
mablejune@otismukinfus.com - 31 Dec 2005 00:04 GMT
>I have a DateTimePicker control that originally displays "1/1/1900" on
>screen.  I want to change it to current date when a user clicks on it.  I use
[quoted text clipped - 6 lines]
>    dtpLastOdoDate.Value = DateTime.Today.Date;
>}

The DateTimeOicker display defaults to the current date and time.  You
must be setting the vale of it to null or something in your code.

Why must the user click the control to get it to display the current
date?  Why not just let it display the default.  If you don't want the
time, just set the Format property to Short.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.