Question

I have an enum:

enum Mangment{
ReportsManagment,
NormalUserManagment,
PowerUserManagment
};

Now, I want to create a checkboxlist and allow the user to chose from this 3 options, than i want to get the selection out back as an enum and process it.

This is my code:

private void saveB_Click(object sender, System.EventArgs e)
    {
        try
        {
            foreach (object itemChecked in rolesPermissionsCBL.CheckedItems)
            {
                var permissionsName = itemChecked.ToString();
                ## How do i get the item checked as an enum..?
            }
         }
     }
Was it helpful?

Solution

Mangment enumValue = (Mangment)Enum.Parse(typeof(Mangment), itemChecked.ToString(), true)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top