PC Review


Reply
Thread Tools Rate Thread

DateTimePicker custom format

 
 
=?Utf-8?B?R2FyeSBNaWxsZXI=?=
Guest
Posts: n/a
 
      15th Feb 2005
Using the custom format "ddd MMMM d h:mm tt".

DataBindings.Text is set to my dataset field.

Control displays properly, I am able to change date values but the moment I
click the save button, text field resets to database value. Debugged the
first statement in the click event.

If I do not use the custom format everything works.

Any ideas




 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      16th Feb 2005
Gary,

I don't understand what you mean with this.

>text field resets to database value.


The database value is nothing more than a value in ticks beginning at a
certain startdate.

Can you clear this a little bit more?

Cor


 
Reply With Quote
 
=?Utf-8?B?R2FyeSBNaWxsZXI=?=
Guest
Posts: n/a
 
      16th Feb 2005
When the form is initiated the DateTimePicker control has what the database
has in it and in the correct format (see first post).

Fri February 18 5:00 PM

Then I change any of the values either through the drop-down calendar or
directly on the control eg - Fri February 18 6:00 PM

I have a button for 'Save' that has a click event. If I debug the first
statement in the click event method, the control 'Text' and 'Value' field
does NOT reflect the changes. And the form control is 'reset' to the
original value.

It appears as though something 'under the covers' has reset the field.
There are NO statements that I can debug on before my click event.

Thanks for your time.

"Cor Ligthert" wrote:

> Gary,
>
> I don't understand what you mean with this.
>
> >text field resets to database value.

>
> The database value is nothing more than a value in ticks beginning at a
> certain startdate.
>
> Can you clear this a little bit more?
>
> Cor
>
>
>

 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      16th Feb 2005
Garry,

I tried it with this piece of code and did not see anything strange.

Maybe you can try it yourself it only needs a new form wiht a datatimepicker
and a button and paste than this piece of code.

DataTable dt;
private void Form3_Load(object sender, System.EventArgs e)
{
dt = new DataTable();
dt.Columns.Add("Gary",Type.GetType("System.DateTime"));
for (int i = 0;i<10;i++)
{
dt.Rows.Add(dt.NewRow());
dt.Rows[i]["Gary"] = DateTime.Now.AddDays(i);
}
dateTimePicker1.DataBindings.Add("Value",dt,"Gary");
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "ddd MMMM d h:mm tt";
}
private void button1_Click(object sender,
System.EventArgs e)
{
CurrencyManager cm = (CurrencyManager) BindingContext[dt];
if (cm.Position>8) cm.Position = -1;
cm.Position++;
}
private void dateTimePicker1_ValueChanged
(object sender, System.EventArgs e)
{
BindingContext[dt].EndCurrentEdit();
}

I hope this helps a little bit?

Cor


 
Reply With Quote
 
=?Utf-8?B?R2FyeSBNaWxsZXI=?=
Guest
Posts: n/a
 
      16th Feb 2005
Cor,

Thanks for your time. I am sure the example works.

My code is has 2 tables in a list/detail relationship. If I try and use the
'Value'' binding I get an exception saying that not all variable can be bound.

Another problem I am working on.

I thought I could get a round it using the 'Text'. I'll try debugging on
the dateTimePicker1_ValueChanged an see any difference.

Thanks

"Cor Ligthert" wrote:

> Garry,
>
> I tried it with this piece of code and did not see anything strange.
>
> Maybe you can try it yourself it only needs a new form wiht a datatimepicker
> and a button and paste than this piece of code.
>
> DataTable dt;
> private void Form3_Load(object sender, System.EventArgs e)
> {
> dt = new DataTable();
> dt.Columns.Add("Gary",Type.GetType("System.DateTime"));
> for (int i = 0;i<10;i++)
> {
> dt.Rows.Add(dt.NewRow());
> dt.Rows[i]["Gary"] = DateTime.Now.AddDays(i);
> }
> dateTimePicker1.DataBindings.Add("Value",dt,"Gary");
> dateTimePicker1.Format = DateTimePickerFormat.Custom;
> dateTimePicker1.CustomFormat = "ddd MMMM d h:mm tt";
> }
> private void button1_Click(object sender,
> System.EventArgs e)
> {
> CurrencyManager cm = (CurrencyManager) BindingContext[dt];
> if (cm.Position>8) cm.Position = -1;
> cm.Position++;
> }
> private void dateTimePicker1_ValueChanged
> (object sender, System.EventArgs e)
> {
> BindingContext[dt].EndCurrentEdit();
> }
>
> I hope this helps a little bit?
>
> Cor
>
>
>

 
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
DateTimePicker - Format Value Terry Microsoft VB .NET 5 29th Mar 2007 08:53 PM
Custom format in DateTimePicker Guy Corriveau Microsoft C# .NET 7 3rd Mar 2005 07:19 AM
DateTimePicker in custom forms Karen Microsoft Outlook Form Programming 1 23rd Aug 2004 07:43 AM
custom datetimepicker control becomes disabled =?Utf-8?B?RGF2aWQgQmF0dA==?= Microsoft VB .NET 0 9th Jun 2004 03:36 PM
Tabbing within a custom datetimepicker nuckinfutz Microsoft VB .NET 0 29th Sep 2003 02:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:59 AM.