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

    <SPAN style="COLOR:#1f497d;"><FONT face=arial,helvetica,sans-serif><FONT color=#000099><FONT size=3>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. </FONT><SPAN style="FONT-FAMILY:'Times New Roman','serif';FONT-SIZE:12pt;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"><FONT size=4>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</FONT></SPAN></FONT></FONT></SPAN>

Need extra support?

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

Learn More

Forum Channels