user459057
user459057

Reputation: 53

DataGridView Winform c#

every time, i press btnAgregar, add "productos" to list.

only the first time the gridview show the first record of the list

after the list grows, but the datagridview don't refrash, showing only the first record.

List<Entidades.Productos> ProductosVenta = new List<Productos>();

 private void btnAgregar_Click(object sender, EventArgs e)
        {
            Entidades.Productos productos = new Entidades.Productos();
            productos = Datos.Productos.ObtenerFormaPagoPorId(int.Parse(txtId.Text));
            ProductosVenta.Add(productos);

            gvVenta.DataSource = ProductosVenta;
        }

Upvotes: 1

Views: 663

Answers (1)

user459057
user459057

Reputation: 53

the solution is make null the data source before asing the list

ProductosVenta.Add(productos);
gvVenta.DataSource = null; // this does the trick
gvVenta.DataSource = ProductosVenta;

Upvotes: 1

Related Questions