I have the following code to set the value as date with time
mRow.Cells("Date").Value = DisplayLongDate("20230603100000")
I stepped thru the code and made sure mRow.Cells("Date").Value is "6/3/2023 10:00 AM"
Then I checked mRow.Cells("Date").Text, it's "6/3/2023"
When the screen is populated, it displays as "6/3/2023", but if I click the field(to edit) it shows "6/3/2023 10:00 AM"
I want it display same as .Value
How do I make sure .Text is same as .Value? Text is read only and I couldn't assign it.,
Hello Mike,
If you would like to have the same format for the Date column inside and outside of edit mode, you can set a DateTimeEditor and set its MaskInput property to the appropriate format you wish to display. Below I am pasting a code snippet that demonstrates how this could be achieved by using the IntializeLayout event of the grid:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { var band = e.Layout.Bands[0]; var col = band.Columns["Date"]; DateTimeEditor dateTimeEditor = new DateTimeEditor(new DefaultEditorOwner(new DefaultEditorOwnerSettings { DataType = typeof(DateTime), MaskInput = "mm/dd/yyyy h:mm:ss tt", } )); col.Editor = dateTimeEditor; } }
Please let me know if you need any further assistance.
Regards, Ivan Kitanov
Thanks, are there any other ways that can manipulates .Text(Outside of editor) I checked the code and we do have MaskInput.
mEditorSettings = New DefaultEditorOwnerSettings() mEditorSettings.FormatProvider = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat mEditorSettings.DataType = GetType(DateTime) mEditorSettings.MaskInput = "{date} {time}" mEditorSettings.Format = DateTimeFormatInfo.CurrentInfo.ShortDatePattern + " " + DateTimeFormatInfo.CurrentInfo.ShortTimePattern
but .Text is still only have the date without time
For testing purpose, I removed the time from above code, the editor only has the date without time which means the code is working.
mEditorSettings.DataType = GetType(Date)mEditorSettings.MaskInput = "{date}"
Thank you!!