Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
How to map enums to comboboxes in C#.
public partial class MappingEnumToComboboxesForm : Form
{
public MappingEnumToComboboxesForm()
{
InitializeComponent();
//Setting the enums as the data sources of the comboboxes
comboBoxNormal.DataSource =
Enum.GetValues(typeof(WdtOscillatorCycles));
comboBoxImproved.DataSource =
Enum.GetValues(typeof(WdtOscillatorCyclesImproved));
}
public WdtOscillatorCyclesImproved WdtOscillatorCyclesOption
{
get
{
//The result must be cast to the enum's type
return (WdtOscillatorCyclesImproved)(comboBoxImproved.SelectedItem);
}
set
{
//You don't need a cast here.
comboBoxImproved.SelectedItem = value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.