Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
UltraGridCell: Text and Value are different
posted

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.,

Parents
No Data
Reply
  • 1700
    Verified Answer
    Offline posted

    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

Children