Enums displaying numbers instead of text in cell

Posted by: tyndaleit on 8 September 2017, 2:39 pm EST

  • Posted 8 September 2017, 2:39 pm EST

    Currently I have a datatable I've populated and changed the column type of to an enum I have defined: 

    enum MyEnum{
      Inactive =0,
      Active = 1,
    };

    The data that then fills this column comes in the form of an Int32 type from a SQL database.  However, when I attach the datatable to a fpSpread.DataSource, the column displays the integer instead of the enumeration's .ToString() output.  This is in contrast to how the DataGridView changes the display text to reflect the enum text.

     My question is what do I have to do to have my Sheet display the text, while holding the correct integer value?

    I even tried to overwrite the value using the enum directly once populated and the number is still displayed

    fswsWorkUnits.Cells[0, 1].Value = Workflows.WorkFlowStatus.Inactive;

  • Replied 8 September 2017, 2:39 pm EST

    You could use a custom celltype that overrides the PaintCell method and changes the value being painted from the number to the ToString of the enum associated with the number. Another suggestion is to use a ComboBoxCellType and set it up with the enum strings in the list, the enum values in the item data, and set EditorValue to EditorValue.ItemData

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels