In a User Registration Form, I have a UF combo box (which loads the data from a sql table), while typing in the combox the system needs to search the data and display despite the ones that match the typed one. I'm doing it this way:
private void carregaComboEstadoCivil()
{
ProfissionalBLL profissional = new ProfissionalBLL();
profissional.carregaComboEstadoCivil(cbxEstadoCivil);
cbxEstadoCivil.KeyPress += new KeyPressEventHandler(cbxEstadoCivil_KeyPress);
}
Professional Class 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);
}
KeyPress Event
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 records that match what I wrote it shows me all the record.