1
I am developing an application that contains a customer register. In this register there is a ComboBox
listing the cities in the database.
My question is this: How do I leave 'setate' the name of a city specifies?
For example: first city that lists by default is 'ABADIA DE GOIAS
', but I would like the city that appears selected to be 'SAO PAULO
', that is there through my list. How can I do that?
Code listing cities in 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();
This is windowns Forms ?
– Amadeu Antunes
That’s right Amadeu, I hadn’t specified, but I’ve corrected.
– user59669