Answer the question
In order to leave comments, you need to log in
How to properly bind data to ComboBox?
List<Scenario> scenarios = new List<Scenario>();
List<Map> maps = new List<Map>();
Scenario scenario = new Scenario();
Scenario scenario1 = new Scenario();
Map map = new Map();
Map map1 = new Map();
scenario.ScenarioID = 1;
scenario1.ScenarioID = 2;
map.Name = "Russia";
map1.Name = "USA";
scenario.Map = map;
scenario1.Map = map1;
maps.Add(map);
maps.Add(map1);
scenarios.Add(scenario);
scenarios.Add(scenario1);
BindingSource source = new BindingSource();
BindingSource source1 = new BindingSource();
source.DataSource = scenarios;
source1.DataSource = maps;
comboBox1.DataSource = source;
comboBox1.DisplayMember = "ScenarioID";
comboBox2.DataSource = source1;
comboBox2.DisplayMember = "Name";
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question