We have a requirement where the date-time should appear in MM/DD/YYYY HH:MM:SS (24 hr) format in the UltraWinGrid in a bound coulmn of data type DateTime.
eg. 05/21/2008 23:45:00
We have tried with the given formats and Styles.
Trying to modify some of the existing formats (tried with {LOC}mm/dd/yyyy hh:mm:ss and mm/dd/yyyy hh:mm:ss) gave some unexpected results, the entered time (23:45:00) got changed to 11:45:00 (AM/PM format but did not display "PM").
Thanks in advance.
Go into your column properties for that Date column and add/change this:
Format (property): MM/dd/yyyy HH:mm:ss
MaskInput (property): {LOC}mm/dd/yyyy hh:mm:ss
Thanks for the solution, but we faced a problem. The given solution works when we tab out or click any where else, but clicking on the cell again makes the time come in 12 hour format (without AM/PM). e.g. DateTime given: 05/21/2000 23:45:01 DateTime on tabout: 05/21/2000 23:45:01 DateTime on cell activation: 05/21/2000 11:45:01 DateTime on tabout again: 05/21/2000 23:45:01 This happens when the particular cell is activated again. On tabbing out, the cell displays time again in 24 hr format. Can you help us with this problem? Thanks in advance.
That must be an issue with the Mask.
The Format property applies to a cell when it is NOT in edit mode.
The MaskInput applies when the cell IS in edit mode. By specifying {LOC} for the mask, it means that the mask will pick up the current culture settings. So the current culture must be set up to use a 12-hour time, not 24. I'm not sure how you force a mask to use 24-hour time. You might want to check the documentation on the MaskInput property and see what the options are. But you probably don't want to use {LOC} in there if you want to force it to always use 24-hour time.
Hi,
I'm having a similar problem with the win editor control. I need day/month/year hour:minute:second i.e.24/02/2008 14:00:00
I want this to stay the same with focus and without. Please tell me the values required for format string and mask.This has been such a pain.
Thanks,
Alex
I managed to get this sorted by setting the MaskInput to '{date} {longtime}'
Hope this helps!
I also have this problem. Is the functionality to display consistently the date time format as 'MM/dd/yyyy HH:mm:ss' with or without focus not supported by Infragistics?
Hi Alex,
A format and a mask are indeed two totally different (albeit related) concepts. But I don't know if it's possible to get them to match exactly. They do different things.
Formatting, as a general rule, is a much simpler process. It's one way. You take a value and you format it for display to the user.
Masks are much more complicated because they have to limit and interpret input by the user and convert that into a value of the appropriate type. So you need to look at the documentation for the MaskInput and see what kind of mask you want to use. I would think the mask would be very similar, but I'm not sure off the top of my head how you specify that the mask should show 24-hour time.
Hi, Thanks for the feedback but I still can't get this working. It seems that the masks/ formats are separate for the fields 'FormatString' and 'Mask Input' i.e. I can't simply copy the mask into both fields as one is interpreted differently. I can get it looking fine when the date picker doesn't have scope by using Microsoft’s recommended formatting. However, when I click in the control it displays the value of the mask entered not the time.
I currently have the format string set to yyyy'-'MM'-'dd HH':'mm':'ss'Z' and correctly displays time as 2008-01-20 14:02:00
Could you please tell what needs to go in the input mask field to ensure a match with and without scope?
Thanks in advance,
I'm not sure off the top of my head, but the Mask should be documented in the MaskInput property. Formats are documented by Microsoft, since all the format does is call the ToString method on the Value. So if you look up DateTime.ToString in msdn, you will find the format you need.