2
In a User Registration Form, I have a combo box UF (which loads the data from an sql table), when writing in Combox the system needs to go searching the data and presenting despite those that coincide with the typed. I’m doing it this way:
private void carregaComboEstadoCivil()
{
ProfissionalBLL profissional = new ProfissionalBLL();
profissional.carregaComboEstadoCivil(cbxEstadoCivil);
cbxEstadoCivil.KeyPress += new KeyPressEventHandler(cbxEstadoCivil_KeyPress);
}
Classe Profissional BLL
public void carregaComboEstadoCivil(ComboBox combo)
{
FuncionsDAL carrega = new FuncionsDAL();
DataTable tabela = carrega.listaEstadoCivil();
DataRow linha = tabela.NewRow();
combo.DropDownStyle = ComboBoxStyle.DropDown;
combo.AutoCompleteMode = AutoCompleteMode.Suggest;
combo.DataSource = tabela;
combo.DisplayMember = "Descricao";
combo.ValueMember = "ID";
combo.Update();
linha["ID"] = 0;
linha["Descricao"] = "Selecione...";
tabela.Rows.InsertAt(linha, 0);
}
Event of the Keypress
private void cbxEstadoCivil_KeyPress(object sender, KeyPressEventArgs e)
{
cbxEstadoCivil.DroppedDown = true;
}
But it’s not working.
The combobox opens allows me to write but not only shows the record that matches what I wrote it shows me all the record.
Post the Keypress event implementation, the way it is just loads the data.
– Julio Borges
private void cbxEstadoCivil_KeyPress(Object Sender, Keypresseventargs e) { cbxEstadoCivil.Droppeddown = true; }
– Tozzi
What’s not working? The data is not shown on the screen or the search does not work?
– Jéf Bueno
Search screen does not work!
– Tozzi