Populating a ComboBox using C#
Define a class
public class Language
{
public string Name { get; set; }
public string Value { get; set; }
}
then...
//Build a list
var dataSource = new List<Language>();
dataSource.Add(new Language() { Name = "blah", Value = "blah" });
dataSource.Add(new Language() { Name = "blah", Value = "blah" });
dataSource.Add(new Language() { Name = "blah", Value = "blah" });
//Setup data binding
this.comboBox1.DataSource = dataSource;
this.comboBox1.DisplayMember = "Name";
this.comboBox1.ValueMember = "Value";
// make it readonly
this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
Create a class Language
public class Language
{
public string Name{get;set;}
public string Value{get;set;}
public override string ToString() { return this.Name;}
}
Then, add as many language to the combobox that you want:
yourCombobox.Items.Add(new Language{Name="English",Value="En"});