Hi JefeSol,
Based on my understanding, you want to use Enum type as the DataSource of ComboBox. But enum type doesn't offer that binding support. Enum.GetValues(typeof(LocalSettings.GroupItemsBy)); will return an Array type object, you are binding comboBox to that array type not the enum type. When doing this, if you retrieve the SelectedValue of ComboBox1, you will see the Text of the selected item.
So I suggest you to create a custom object first and make a list of it. Here is an example
public class MyType
{
private int id;
public int Id
{
get { return id; }
set { id = value; }
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
public MyType(int id, string name)
{
this.id = id;
this.name = name;
}
}
You can use it as below
List<MyType> myList = new List<MyType>();
myList.Add(new MyType(1, "Item1"));
myList.Add(new MyType(2, "Item2"));
comboBox1.DataSource = myList;
comboBox1.DisplayMember = "Name";
comboBox1.ValueMember = "Id";
If I misunderstood you, please feel free to tell me.
Sincerely,
Kira Qian
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the
All-In-One Code Framework!