sum the values of the repeated names in Datagridview

Asked

Viewed 27 times

0

Hello, folks all right, I have an application where I add the items in Datagridview, however I want to add the volume values, the lines that are with the same name, I want to create a variable to receive the repeated name and the sum of the values, I have the example code and I’ll show you so you can help me because I’m not getting.

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

  • avoid placing images, put the code in the question, it is much more readable

  • perfect friend, I’ll do it thank you.

  • where the data from dgv ? where there is EF in the code ?

  • data is coming from textbox and being add to datagrig.

  • private void btnAionar_Click(Object Sender, Eventargs and) {
 CamposGrid();
 dtCargas.Rows.Add lblCodigo.Text, txtNomePopular.Text, txtPlaqueta.Text 
 txtCoc.Text, txtPicada.Text,txtSecTora.Text, txtD1Dof.Text, txtD2Dof.Text,
 txtCompDof.Text, txtVolumeDof.Text, txtD1.Text, txtD2.Text, txtComp.Text, txtVolumeCompra.Text, txtPatio.Text, txtSomaEspecie.Text, txtCodigo.Text, dateTimePicker1.Text); }

  • In my view I would add the form data in a LIST, then move the list to the grid, because that way it would be easy to do what you want. I would use Linq, with SUM and DISTINCT to sum the desired values where the name repeated.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.