I have a problem with enum description. I want that the dataGrid show me the enum description and not "ToString()" of the enum.
enum DirectionEnum
{
[Description("Right to left")]
rtl,
[Description("Left to right")]
ltr
}
class Simple
{
[DisplayName("Name")]
public string Name { get; set; }
[DisplayName("Direction")]
public DirectionEnum dir { get; set; }
}
class DirectionDialog : Form
{
public DirectionDialog()
{
DataGridView table = new DataGridView();
List<Simple> list = new List<Simple>(new Simple[]{
new Simple{ Name = "dave", dir = DirectionEnum.ltr},
new Simple{ Name = "dan", dir = DirectionEnum.rtl }
});
table.DataSource = list;
//view "rtl" or "ltr" in "Direction"
//I want "Right to left" or "Left to right:
}
}
I want to view the direction column by the description of the enum. What do I doing? Sorry for my bad English.