PC Review


Reply
Thread Tools Rate Thread

DateTimePicker and saving time only..

 
 
Aaron Smith
Guest
Posts: n/a
 
      22nd Nov 2004
How do you get the datetimepicker to save only the time to a databound
field? I have tried format and parse, and the functions work, getting
the cevent.value = "1:25 PM" but it always saves the current date along
with it.. I also have the custom format property set to "hh:mm tt" and
the format and parse have thier formatting set to the same...

Private Sub FormatTime(ByVal sender As Object, ByVal cevent As
ConvertEventArgs)
If Not cevent.DesiredType Is GetType(DateTime) Then
Exit Sub
End If
cevent.Value = CType(cevent.Value,
System.DateTime).ToString("hh:mm tt")
End Sub

Private Sub ParseTime(ByVal sender As Object, ByVal cevent As
ConvertEventArgs)
If Not cevent.DesiredType Is GetType(DateTime) Then
Exit Sub
End If
cevent.Value = CType(cevent.Value,
System.DateTime).ToString("hh:mm tt")
End Sub

Thanks,
Aaron

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
 
Reply With Quote
 
 
 
 
Aaron Smith
Guest
Posts: n/a
 
      23rd Nov 2004
Fixed it myself. Used a char field instead of datetime.

Aaron Smith wrote:
> How do you get the datetimepicker to save only the time to a databound
> field? I have tried format and parse, and the functions work, getting
> the cevent.value = "1:25 PM" but it always saves the current date along
> with it.. I also have the custom format property set to "hh:mm tt" and
> the format and parse have thier formatting set to the same...
>
> Private Sub FormatTime(ByVal sender As Object, ByVal cevent As
> ConvertEventArgs)
> If Not cevent.DesiredType Is GetType(DateTime) Then
> Exit Sub
> End If
> cevent.Value = CType(cevent.Value,
> System.DateTime).ToString("hh:mm tt")
> End Sub
>
> Private Sub ParseTime(ByVal sender As Object, ByVal cevent As
> ConvertEventArgs)
> If Not cevent.DesiredType Is GetType(DateTime) Then
> Exit Sub
> End If
> cevent.Value = CType(cevent.Value,
> System.DateTime).ToString("hh:mm tt")
> End Sub
>
> Thanks,
> Aaron
>



--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
 
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
How to set DateTimePicker only edit time ? cyshao Microsoft C# .NET 1 31st Mar 2005 04:26 AM
DateTimePicker - A date or a time, how to do both? Robin Tucker Microsoft VB .NET 2 9th Feb 2005 05:52 PM
DateTimePicker - Time value? Chris Ashley Microsoft Dot NET Framework Forms 3 19th Oct 2004 04:42 PM
Where is the Time in DateTimePicker Control? =?Utf-8?B?UGV0ZXI=?= Microsoft C# .NET 1 12th Apr 2004 06:35 PM
Re: HOW TO: Select Time using DateTimePicker Herfried K. Wagner [MVP] Microsoft Dot NET Framework Forms 0 26th Mar 2004 09:43 PM


Features
 

Advertising
 

Newsgroups
 


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