What else I have to do in order to show ReadAccess
enum members in this DatagridViewComboBox?
ReadDataGridViewComboBoxColumn.Items.Clear();
ReadDa
An Improvement to accepted answer:
There is no need to type enum members as array manually. Instead you can use System.Enum.GetValues(typeof(ReadAccess))
. Also, instead of anonymous type list, you can use a List from Dictionary (Dictionary isn't accepted as datasource):
ReadDataGridViewComboBoxColumn.DataSource= System.Enum.GetValues(typeof(ReadAccess))
.Cast.ToDictionary((e) => e.ToString(), (e) => e).ToList;
or directly a KeyValuePair list :
ReadDataGridViewComboBoxColumn.DataSource = System.Enum.GetValues(typeof(ReadAccess))
.Cast.Select((value) => new KeyValuePair(value.ToString(), (value)));
Still necessary (but DisplayMember now is "Key") :
ReadDataGridViewComboBoxColumn.ValueType = typeof(ReadAccess);
ReadDataGridViewComboBoxColumn.ValueMember = "Value";
ReadDataGridViewComboBoxColumn.DisplayMember = "Key";