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
1878
Individual formatting of Data Cells
posted

Hi there,

I've several questions concerning individual formatting of data cells in a DataGrid. I've set the column to be of type string but want to override this type for some cells to be e.g. a DateTime or Decimal type. To a certain extent I succeeded doing that but I missing some parts to meet the requirements. Here are my questions one by one:

  1. Formatting of a DateTime Cell. I've added one line to my code:

    ultraGrid.Rows[0].Cells[0].Style = ColumnStyle.Date

    This shows a Date Picker for that cell which is perfect and also after a date is selected it is shown in the cell but the question is how can I change the format of that date since it seems that it is displayed in local date format but I want to show it differently?
  2. For displaying a currency value I want to display a character for seperating multiples of thousands. I'm using an UltraNumericEditor as the EditorControl for that cell where I set both the MaskInput and the FormatString and during typing (cell has focus) this shows perfectly what I want. As soon as the cell does not have the focus anymore it doesn't display the characters for seperating multiples of thousands. The decimals are presented correctly. I also tried UltraMaskedEdit instead of UltraNumericEditor and the result was the same.

    Here is the small code snippet:

    ultraGrid.Rows[1].Cells[0].CellDisplayStyle = CellDisplayStyle.FormattedText;
    var numericEditor = new UltraNumericEditor {
         NumericType = NumericType.Decimal,
         MaskInput = "n,nnn,nnn.nn",
         FormatString = "n,nnn,nnn.nn"};
    ultraGrid.Rows[1].Cells[0].EditorControl = numericEditor;

    I've also tried it without setting CellDisplayStyle but that didn't help either.

Thanks in advance,
  Wolfgang

  • 469350
    Offline posted

    Wolfgang Pöchgraber said:
    Formatting of a DateTime Cell. I've added one line to my code:

    ultraGrid.Rows[0].Cells[0].Style = ColumnStyle.Date

    This shows a Date Picker for that cell which is perfect and also after a date is selected it is shown in the cell but the question is how can I change the format of that date since it seems that it is displayed in local date format but I want to show it differently?

     

    I think you would have to use an editor. Instead of setting the Style of the column, place an UltraDateTimeEditor on the form and set the EditorControl property of the cell to this control. Then you can set up the mask settings on the UltraDateTimeEditor however you like. You will need to set UseEditorMaskSettings to true on the column to tell it to use the UltraDateTimeEditor mask settings, instead of the settings on the column.

     

    Wolfgang Pöchgraber said:
    For displaying a currency value I want to display a character for seperating multiples of thousands. I'm using an UltraNumericEditor as the EditorControl for that cell where I set both the MaskInput and the FormatString and during typing (cell has focus) this shows perfectly what I want. As soon as the cell does not have the focus anymore it doesn't display the characters for seperating multiples of thousands. The decimals are presented correctly. I also tried UltraMaskedEdit instead of UltraNumericEditor and the result was the same.

    Here is the small code snippet:

    ultraGrid.Rows[1].Cells[0].CellDisplayStyle = CellDisplayStyle.FormattedText;
    var numericEditor = new UltraNumericEditor {
         NumericType = NumericType.Decimal,
         MaskInput = "n,nnn,nnn.nn",
         FormatString = "n,nnn,nnn.nn"};
    ultraGrid.Rows[1].Cells[0].EditorControl = numericEditor;

    I've also tried it without setting CellDisplayStyle but that didn't help either.

    I think you may be able to get this work by setting the MaskDisplayMode on the Numeric editor. If that does not work, then the only thing you can do is use a DataFilter to format the text yourself.