6

Formatting at cell level Ultrawingrid Infragistics

 2 years ago
source link: https://www.codesd.com/item/formatting-at-cell-level-ultrawingrid-infragistics.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Formatting at cell level Ultrawingrid Infragistics

advertisements

I have an Infragistics UltraWinGrid bound to a datasource which contains an amount (decimal) and a currency (string). I need to display the amount and currency formatted:

Data source:          Grid contents:
Amount   Currency     Amount
12.34    EUR          EUR 12.34
22.33    USD          USD 22.33

I am thinking about 3 options:

  1. Populate the "Amount" column in the grid with a formatted string. I don't like this option because it would mess up the sorting of decimal values.
  2. Set an editor on each CELL (Cell, not Column!) in the InitializeRow event. However, I don't know which editor would be suitable - any ideas?
  3. Format the Amount column (Column level!) in the InitializeLayout method somehow dependant on the Currency column (the Currency column exists in the grid as a hidden column) - but I don't know if this is possible - does anybody know how? Or are there any other suggestions?

I have done it using option 2 using a EditorWithText. I have 2 columns in a row - a Decimal Value column and string FormatString column. Here's what I did to have independent formatting in the Value column.

grid.InitializeRow += (sender, e) =>
{
    DefaultEditorOwnerSettings settings = new DefaultEditorOwnerSettings();
    settings.DataType = typeof(Decimal);
    settings.Format = (string)e.Row.Cells["FormatString"].Value;
    EditorWithText editor = new EditorWithText(new DefaultEditorOwner(settings));
    e.Row.Cells["Value"].Editor = editor;
}


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK