PC Review


Reply
Thread Tools Rate Thread

Date Time Picker control

 
 
Mike
Guest
Posts: n/a
 
      12th Nov 2007
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

 
Reply With Quote
 
 
 
 
Marc Gravell
Guest
Posts: n/a
 
      12th Nov 2007
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);
}

}
}

 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      12th Nov 2007


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
<(E-Mail Removed)> wrote:

>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);
> }
>
> }
>}

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting current date on date/time picker control =?Utf-8?B?RG91Z00=?= Microsoft Access VBA Modules 1 19th Jul 2005 07:07 PM
I am trying to use the Microsoft Date and Time Picker control and I am getting the following error "an error occured in a call to the windows date and time picker control" in access 2000 Ralph Malph Microsoft Access Forms 0 25th Oct 2004 07:00 PM
MS Date and Time Picker Control defaults to today's date =?Utf-8?B?UmF2aQ==?= Microsoft Outlook VBA Programming 1 22nd Jan 2004 02:48 PM
Problem with Date & Time Picker control in a Tab Control form Mystery Microsoft Access Form Coding 0 2nd Aug 2003 11:43 AM
Problem with Date & Time Picker control in a Tab Control form Mystery Microsoft Access Forms 0 2nd Aug 2003 11:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:46 AM.