Skip to content

Custom format string per cell

New Discussion
Daniel Roth
Daniel Roth asked on Nov 16, 2017 5:16 PM

Dear Infragistics support,

I’m trying to fulfil the following requirements for a grid with all bound columns:

  • Edit a cell value in a dedicated column with the fixed input mask {double:-8.6}
  • Display the cell value in the dedicated column with a custom format string (percentage, integer value, numeric with variable precision)
  • The format string is variable per cell, i.e. not equal for all cells of the deciated column

The expected behaviour is, that the raw value is displyed in edit mode as defined in input mask. Whenever the edit mode terminates, the formatting applies to the dedicated cell.

The data type of the affected bound column in my example is Nullable<decimal>. My attempts to realize the requirements have failed so far using the following approaches:

  1. Assign the UltraGridCell.Editor an EditorWithMask instance with set MaskInput and FormatString property values in InitializeRow event of the grid.
    The expected formatting didn’t apply after exiting the edit mode.
  2. Assign the UltraGridCell.EditorComponent an UltraNumericEditor instance with set MaskInput and FormatString property values in InitializeRow event of the grid.
    Only the input mask seems to apply, but not the format string.

I’m aware to set UseEditorMaskSettings = true for the dedicated column.

What do I miss or is there a different, more promising approach? By reading other posts, I stumbled over the usage of a custom data filter to handle the custom formatting.

I kindly expect your response.

Sign In to post a reply

Replies

  • 0
    Michael Peterson
    Michael Peterson answered on Nov 14, 2017 4:32 PM

    Hello,

    Thank you for contacting Infragistics!

    I am attaching a sample that demonstrates this behavior of setting a different format for each cell.

    • 0
      Daniel Roth
      Daniel Roth answered on Nov 16, 2017 5:16 PM

      Thank you very much for providing the sample project. The approach I used is quite similar to the one in the code sample.

      My issue was basically, that the designer code of the UltraGrid assigned to the Format property of the associated UltraGridColumn string.Empty = " " as Format. This format definition always overrid my definition from the editor in InitializeRow event.

      As soon as I removed this assignment in the designer code, my solution worked perfectly.

      Conclusion:

      • Remove any definitions for the input mask or the format in UltraWinGrid designer for the column
      • Set UseMaskEditorSettings to true in UltraWinGrid designer for the dedicated column
      • Remove legacy assignments for the input mask and the format in designer code of UltraWinGrid
      • Enable custom per row / cell formatting

      In order to optimize memory usage I created an editor instance per format and cached it internally.

      Code sample attached.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Daniel Roth
Favorites
0
Replies
2
Created On
Nov 16, 2017
Last Post
8 years, 3 months ago

Suggested Discussions

Created by

Created on

Nov 16, 2017 5:16 PM

Last activity on

Feb 19, 2026 7:39 AM