473,387 Members | 1,379 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,387 software developers and data experts.

The code to change dateTimePicker control not working.

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;
}
Dec 29 '05 #1
5 5420
dtpLastOdoDate.Update(); // ??

"Alpha" wrote:
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;
}

Dec 30 '05 #2
Thanks John. I added the code you suggested
dtpLastOdoDate.Update();
but it still not working.

"John" wrote:
dtpLastOdoDate.Update(); // ??

"Alpha" wrote:
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;
}

Dec 30 '05 #3
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.

Dec 30 '05 #4
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.

"chandra" wrote:
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.

Dec 30 '05 #5
On Thu, 29 Dec 2005 12:37:02 -0800, "Alpha"
<Al***@discussions.microsoft.com> wrote:
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;
}


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.
Dec 31 '05 #6

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

Similar topics

2
by: Richard | last post by:
Hi, I have a DateTime picker control on a form. The datetime picker control is data bound to a column in a DataTable. Yes I know about bound DateTime pickers and DBNull and etc. so no troubles...
4
by: Jacek Jurkowski | last post by:
.... the minimum date of DateTimePicker is 1753-01-01. How to make DateTime to do not show nothing in its text if this date is the value? I have a form with a field LastLogonDate. If user hasn't...
4
by: Craig831 | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
3
by: Darin | last post by:
Is there a way to, at runtime, change a textbox to be a datetimepicker? I have a form that I allow the user to specify what field types the input boxes are. They can be regular text, integer,...
8
by: gumi | last post by:
Hi, I am looking for code for a alarm clock program that pops up a messege to be used as part of my VB.Net class project. Any help is very much appreciated. Thanks
7
by: Clamara | last post by:
When adding a new record from my form, I pre-set my DateTimePicker's value to System.DateTime.Today Since the "Today" value is used most of the time, the user doesn't need to select a date from...
3
by: Charlie | last post by:
In the top portion of the DateTimePicker, where the value of the date is displayed, how can I detect whether the month or day or year is currently focused, or, if ShowCheckBox = True, whether the...
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...
2
by: Todd Carnes | last post by:
I am trying to write an app in C# that requires the user to enter a date from 4000 B.C.E to 4000 C.E. I tried to use the DateTimePicker Control to allow the user to enter the date, but it only...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.