Time format with DatetimeEditor

This post has 6 Replies | 5 Followers

idisisi
Points 380
Replied On: Mon, Mar 3 2008 10:21 AM

Hi,

 How to get Just a time format with DateTimeEditor?

I've tried to put FormatString in "t" but i get 01/01/2008 00:00:00
I've tried to put MaskInpu to {time} i get the same result...

Please help.

Thanks

  • Post Points: 20
[Infragistics] Sung Kim
Points 10,880
Infragistics Employee
Replied On: Thu, Mar 20 2008 4:41 PM

As you mentioned setting the MaskInput to {time} should get the behavior you are looking for.  If you only set the FormatString property, the the time will display only when the control is in edit mode (when the cursor is in the control).  I tested with Visual Studio 2005 and NetAdvantage 2007 Volume 3, 7.3.20073.38, and did not have any issues.  Are you possibly using Visual Studio 2008 with a version prior to NA 2008 Volume 1?

I would not use the DateTimeEditor if all you are interested in is time.  It is more of a date chooser then a time picker. 

Instead, use a UltraMaskEdit control.  Set the EditAs property to DateTime and InputMask to {time}. 

  • Post Points: 20
rblanchard
Points 2,055
Replied On: Thu, Jan 24 2013 9:02 AM

If I use the UltraMaskEditor, set the EditAs to DateTime and the InputMask is set to to {time} can I save to my DB just the time? Right now if I set to what you mention what is written tot he DB is the full DATE/TIME. I would just like the time (HH:MM AM).

Roger Blanchard

  • Post Points: 20
Replied On: Fri, Jan 25 2013 3:23 AM

Hello,

You could retrieve the needed information by using the following code:

     ((DateTime)ultraMaskedEdit1.Value).ToShortTimeString();

Please feel free to let me know if I misunderstood you or if you have any other questions.


Best regards,

Boris

Developer Support Supervisor, MCPD
Infragistics, Inc.

How to get answers =>

  • Post Points: 20
rblanchard
Points 2,055
Replied On: Fri, Jan 25 2013 7:12 AM

This control is bound to a datasource so I want the value to be written to the DB with just the time. Would I need to use a datafilter to do this?

Roger Blanchard

  • Post Points: 20
Mike Saltzman
Points 441,400
Infragistics Employee
Replied On: Fri, Jan 25 2013 10:54 AM

Hi Roger,

You could try a DataFilter, but I'm not sure if that will work.

You would probably be better off using the Parse and Format methods of the Binding - assuming that you don't need the Date portion in your code.

Mike Saltzman

Manager - Windows Forms Development

Infragistics, Inc.

  • Post Points: 20
rblanchard
Points 2,055
Replied On: Fri, Jan 25 2013 1:09 PM

Okay, thanks.

Roger Blanchard

  • Post Points: 5
Page 1 of 1 (7 items) | RSS