How to show Enum type members in a DataGridViewComboBox?

后端 未结 4 915
醉酒成梦
醉酒成梦 2021-02-03 10:30

What else I have to do in order to show ReadAccess enum members in this DatagridViewComboBox?

ReadDataGridViewComboBoxColumn.Items.Clear();
ReadDa         


        
4条回答
  •  失恋的感觉
    2021-02-03 11:19

    Adding to the answer Bradly Smith provided: One can get all Enum values (instead of naming each individually) easily using this code:

        ReadDataGridViewComboBoxColumn.DataSource =
            new List((ReadAccess[]) Enum.GetValues(typeof(ReadAccess)))
            .Select(value => new { Display=value.ToString(), Value=(int)value })
            .ToList();
    

提交回复
热议问题