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

Date Time Picker control

Hi to all,

I'd like to set initial value to DateTimePicker Control
programmatically, How I can do that?

I had tried following:

1. DataTable dt = dataLayer.GetOffer(OfferID);
this.dtpOfferDate.Value =
Convert.ToDateTime(dt.Rows[0][6].ToString());

2. I tried:
this.dtpOfferDate.Value = Convert.ToDateTime(dt.Rows[0][6]);

It doesnt works too, shows only current date...

On the same time, for text box works fine...

this.txtOfferDate.Text = dt.Rows[0][6].ToString();

Please help. Thanks in advance good people

Nov 12 '07 #1
2 4195
Well, the code (at the bottom) works fine; I would suggest breaking
the expression and checking the values, i.e.
DateTime tmp = Convert.ToDateTime(dt.Rows[0][6]);
// breakpoint/output! what is tmp?
this.dtpOfferDate.Value = tmp;

And you might want to double-check that dtpOfferDate is the correct
control and isn't already data-bound, and doesn't have any conflicting
min/max values.

Marc

using System;
using System.Windows.Forms;

static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
using (Form f = new Form())
using (DateTimePicker dtp = new DateTimePicker())
{
dtp.Value = new DateTime(1960, 11, 13);
f.Controls.Add(dtp);
Application.Run(f);
}

}
}

Nov 12 '07 #2


Hi Marc,

it's works. You are really good! Thanks.

Sincerelly, I do not understand where is difference, but it's works.

Thanks.
Mike

On Mon, 12 Nov 2007 07:27:04 -0800, Marc Gravell
<ma**********@gmail.comwrote:
>Well, the code (at the bottom) works fine; I would suggest breaking
the expression and checking the values, i.e.
DateTime tmp = Convert.ToDateTime(dt.Rows[0][6]);
// breakpoint/output! what is tmp?
this.dtpOfferDate.Value = tmp;

And you might want to double-check that dtpOfferDate is the correct
control and isn't already data-bound, and doesn't have any conflicting
min/max values.

Marc

using System;
using System.Windows.Forms;

static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
using (Form f = new Form())
using (DateTimePicker dtp = new DateTimePicker())
{
dtp.Value = new DateTime(1960, 11, 13);
f.Controls.Add(dtp);
Application.Run(f);
}

}
}
Nov 12 '07 #3

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

Similar topics

5
by: Adrian Parker | last post by:
Hi. I have a date time picker in my program which uses ADO to read from an Access database. It works perfectly, unless the database is empty (no records) when opened. When you try to open an...
13
by: Deano | last post by:
Hi, I generate a report using two dates (From and To). I notice if I enter 01/10/2003 that it is interpreted by Access as 10/01/2003 i.e 10th January rather than 1st October as I intended. ...
3
by: TD | last post by:
This code doesn't work. Every posting I can find suggests that it should. If TypeOf controlname Is DTPicker then do something here End If I am using the Date Time Picker control and wish to...
2
by: Need Helps | last post by:
The example given in msdn.com on how to create a Date Time Picker involves using the CreateWindowEx function. However, I created a dialog box using the graphical interface, and then used the...
4
by: Michael Turner | last post by:
Hi Guys I have two DateTime pickers one shows the Date and the other the time, this is a requirement of the solution. The problem I have is that when the time is saved to the sql database into a...
2
by: Darhl Thomason | last post by:
I'm converting my Access 2003 VBA app. I have a number of date fields in my db that I want to use the date/time picker control with, but if there is no entry in my database, I want the date/time...
4
by: Michel Posseth [MCP] | last post by:
I have a problem with the date time picker validate event wich i believe is a bug How to reproduce : throw on a form a date time picker control and a textbox control select the validating...
3
by: luanhoxung | last post by:
hi all ! i have a date & time picker control bound to 1 field. it worked fine. But i always get the message :" Can't set value to Null when checkbox properties = FALSE" when i open my form. there...
0
by: fredloh | last post by:
i have a tab control on my form. i then have several microsoft date and time picker control on the tab control. when i select a date on any of the date and time picker control, the result of the...
1
by: Sabbuser | last post by:
Hey Guys please help me out!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! I have placed a Date & Time Picker Control on a form in Windows 2000, When our Organization has upgraded all the PC's with...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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.