1
I am using the following code to include items in a list and show them in mine DataGridView
:
PedidodetalheOffline item = new PedidodetalheOffline(); //crio um novo item
item.IdOffline = id; //seto o id
item.PedidoOffline = numero; //seto o numero do pedido
item.ItemOffline = iditem; //seto o item
pedido.Add(item); //adiciono o item à lista "pedido"
id++; //incremento a variavel id para nao repetir
MessageBox.Show(pedido.Count().ToString()); //quantidade de intens que tem na lista
gridPedido.DataSource = pedido; //passo a lista pro DataGridView
This is the code of the button that includes items in the list and passes to DataGridView
. What happens is that the first time it works (the first item is shown inside the DataGridView
), but from the second, it doesn’t work (keeps showing only the first). Included the MessageBox
to confirm that items are being included in the list and confirmed that they are.
What can it be? Do you have any commands to update the list or the DataGridView
each time I include a new item?
pedido
is what?– novic
request is the list
– Italo Rodrigo
writes like this
gridPedido.DataSource = pedido.ToList()
– novic
@Virgilionovic worked perfectly! Thanks. If you want, post the answer for me to score. Hug.
– Italo Rodrigo