I have a simple enum:
public enum Status
{
sad,
happy
};
protected Status status;
I have successfully binded its values to a combobox:
cmbStatus.DataSource = Enum.GetValues(typeof(StatusClass.Status));
I now want the selected item/value/index of the combobox to be retrievable. But I am having trouble. I've tried encapsulating the enum, then retrieving its value, like so:
public Status StatusType
{
get { return status; }
set { stats = value; }
}
person.StatusType = cmbStatus.SelectedItem.ToString();
This gives me this error: "Cannot implicitly convert type 'string' to StatusClass.Status.Status'.
I've tried getting the enum names (e.g. 'sad' and 'happy' as text rather than its value) like so (but am not sure how to encapsulate this, nor sure whether it is working):
string statusType = Enum.GetName(typeof(Status), status);
If I can encapsulate this, perhaps I'll solve my issue. I'm stumped at this point; I'm a newbie. Any help's sincerely appreciated. Here's hoping this all makes sense, and gives sufficient information. Thanks.