while (reader.Read())
{
combobox1.Items.Add(reader["SomeFieldName"].ToString());
}
Do you fill a list and set the list as a datasource for the combobox; e.g. -
List<SomeObject> objects = new List<SomeObject>()
while (reader.Read())
{
objects.Add(new SomeObject() { SomeFieldName = reader["SomeFieldName"].ToString() });
}
combobox1.DataSource = objects;
try
{
SqlConnection read = Cts.Login.ConnectRead();
SqlCommand mycom = read.CreateCommand();
mycom.CommandText = "SELECT Selection " +
"FROM ItemsQuinc ORDER BY Selection ASC";
SqlDataAdapter da = new SqlDataAdapter(mycom);
DataSet dataSet = new DataSet();
da.Fill(dataSet);
itemComboBox.DataSource = dataSet.Tables[0];
itemComboBox.DisplayMember = "Selection";
read.Close();
read.Dispose();
}
catch (SqlException ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
return;
}
-saige-