I am trying to add a value to a combobox. I can set the text, but not the value. I know I can populate the combobox with a datatable, but I want to do it manually to keep full control of the data display. I can do the ComboBox.Items.Add(), but that just sets the text. How do I add the value (which will be a primary key, different from the text)?
public Form1()
{
InitializeComponent();
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Drew\Documents\Visual Studio 2012\Projects\Football\Football\db\FB_DB.mdb;User Id=admin;Password=;");
//Load QB DropDown
conn.Open();
OleDbCommand cmd = new OleDbCommand("select PlayerID,LastName,FirstName from tb_players where Pos = 'QB' Order By LastName", conn);
OleDbDataReader reader = cmd.ExecuteReader();
string plyrName = "";
while (reader.Read())
{
plyrName = reader["LastName"].ToString() + ", " + reader["FirstName"].ToString();
cbQb.Items.Add(plyrName);
}
conn.Close();
}