I populate my combo boxes with a binding source using a dictionary, however this results in the top of the list being visible as default.
I'd like to have the combo box display nothing after it has been populated, as events trigger when the user selects a dropdown option(SelectedIndexChanged). So with an option which may be the one they need they have to select it even though it appears to already be selected.
Dictionary creation:
public Dictionary<int, string> Get_List_of_SchemesID()
{
Dictionary<int, string> comboSource = new Dictionary<int, string>();
using (SqlConnection cnn = new SqlConnection(connectionString))
{
cnn.Open();
string query = "SELECT [idGMRScheme],[SchemeName] FROM [DBA_Admin].[dbo].[GMR_Schemes]";
using (SqlCommand command = new SqlCommand(query, cnn))
using (SqlDataReader reader = command.ExecuteReader())
while (reader.Read())
{
comboSource.Add((int)reader["idGMRScheme"], (string)reader["SchemeName"]);
}
}
return comboSource;
}
Combo population:
public void Populate_SchemesID_Combolists(Dictionary<int, string> comboSource)
{
cb_Schemes.DataSource = new BindingSource(comboSource, null);
cb_Schemes.ValueMember = "Key";
cb_Schemes.DisplayMember = "Value";
}