I'm developing an application that contains a customer registry. In this register there is a ComboBox
that lists the cities of the database.
My question is: How do I leave ' setado ' the name of a specific city?
For example, the first city that lists by default is ' ABADIA DE GOIAS
', however I would like the selected city to be ' SAO PAULO
', which is in the middle of my list. How can I do this?
Code that lists cities in the ComboBox:
String nomeConexao = LoginInfo.StringConexao;
String string_conn = ConfigurationManager.ConnectionStrings[nomeConexao].ConnectionString;
SqlConnection conn = new SqlConnection(string_conn);
String scom = "SELECT COD, CIDADE FROM CODMUNICIPIO ORDER BY CIDADE";
SqlDataAdapter da = new SqlDataAdapter(scom, conn);
DataTable dtResultado = new DataTable();
dtResultado.Clear();
CbCidade.DataSource = null;
da.Fill(dtResultado);
CbCidade.DataSource = dtResultado;
CbCidade.ValueMember = "COD";
CbCidade.DisplayMember = "CIDADE";
CbCidade.SelectedItem = "";
CbCidade.Refresh();