Search code examples
c#.netenumsinfragisticsultrawingrid

Show text portion in instead of numerical of enum in column


I am using infragistic's ultragrid and I want to show the text portion of a enum property. I tried doing it like so

private void MapToLevel()
{
   foreach (var row in HistoryGrid.Rows)
    {
       row.Cells["LevelId"].Value = row.Cells["LevelId"].Value.ToString();
    }
}

this doesn't change anything.

this method is being called here

public new void Refresh()
 {
    LoadData();
    HistoryGrid.DataSource = null;
    HistoryGrid.DataSource = _BindingSource;
    HistoryGrid.DataBind();
    MapToLevel();
}

private void LoadData()
{
   _histories = _controller.GetAll(_personId, _companyId);
   _BindingSource = new BindingSource { DataSource = _histories };
}

Solution

  • You will need to get the name of the enum:

    row.Cells["LevelId"].Value = Enum.GetName(typeof(YourEnum), row.Cells["LevelId"]);