Dear colleagues.
I want to find a Datagrid from a list. The detail is that I want to select the columns to be displayed. If you do not inhibit the auto-generation of the columns there is usually the data. But if you inhibit auto generation, it shows the created columns + the bank columns, but it does not display the data.
Here is the snippet of the routine:
private void frmCFOPPesquisar_Load(object sender, EventArgs e)
{
dgvPesquisar.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dgvPesquisar.AutoGenerateColumns = false;
ConfiguraDGV();
CarregarGrid();
}
public void ConfiguraDGV()
{
dgvPesquisar.Columns.Add("cfop", "CFOP");
dgvPesquisar.Columns.Add("Descricao", "Descrição");
dgvPesquisar.Columns.Add("NaturezaOperacao", "Natureza de Operação");
}
public void CarregarGrid()
{
BancoContexto contexto = new BancoContexto();
IEnumerable<Cfop> lista = from p in contexto.Cfops select p;
dgvPesquisar.DataSource = lista.ToList();
}
Thank you.