private void TextPesquisar_TextChanged(object sender, EventArgs e) { try { List <EstoquePeca> estoquePecas = _estoquePecasController.Pesquisar(textPesquisar.Text); DataTable dt = new DataTable(); dt.Columns.Add("ID", typeof(int)); dt.Columns.Add("Descrição", typeof(string)); dt.Columns.Add("Valor", typeof(double)); dt.Columns.Add("Quantidade", typeof(int)); foreach (EstoquePeca estoquePeca in estoquePecas) { dt.Rows.Add(estoquePeca.Id, estoquePeca.Descricao, estoquePeca.ValorUnit, estoquePeca.Quantidade); } ListaEstoquePecas = estoquePecas; dgEstoqueConsulta.DataSource = dt; } catch (ConcorrenciaBancoException ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }