astonmartin
New member
- Joined
- Sep 12, 2024
- Messages
- 3
- Programming Experience
- Beginner
Hello,
I select the row in DGV1 that I need and add it to DGV2,
in DGV1 I have the columns “Quantity”, “E-Price” and “Total”, in DGV2 I have the same columns.
What I came across is that when I changed the quantity in DGV1 from 1 piece to 2 pieces
a decimal place is missing in DGV2 column “Total”, this always happens when I enter an even number in DGV1
but not with odd numbers.
Example:
in DGV1 column “Quantity” is 1 piece, E-price 40,90 € = total 40,90 €, in DGV2 also the same.
If I now change the quantity in DGV1 to 2 pieces, €40.9 appears in DGV2 in the “Total” column.
DGV1 is bound, DGV2 is unbound
Here is the code how I add the row from DGV1 to DGV2:
Don't get the error...
Greetings Andi
I select the row in DGV1 that I need and add it to DGV2,
in DGV1 I have the columns “Quantity”, “E-Price” and “Total”, in DGV2 I have the same columns.
What I came across is that when I changed the quantity in DGV1 from 1 piece to 2 pieces
a decimal place is missing in DGV2 column “Total”, this always happens when I enter an even number in DGV1
but not with odd numbers.
Example:
in DGV1 column “Quantity” is 1 piece, E-price 40,90 € = total 40,90 €, in DGV2 also the same.
If I now change the quantity in DGV1 to 2 pieces, €40.9 appears in DGV2 in the “Total” column.
DGV1 is bound, DGV2 is unbound
Here is the code how I add the row from DGV1 to DGV2:
VB.NET:
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
'Copy selected rows from Datagridview1 to Datagridview2
Datagridview2.ColumnCount = 5 'Number of columns
For Each dgvRow In DataGridView1.SelectedRows
Dim row3() As String = {dgvRow.Cells(1).Value.ToString(), dgvRow.Cells(6).Value.ToString(), dgvRow.Cells(3).Value.ToString(), dgvRow.Cells(7).Value.ToString() , dgvRow.Cells(7).Value.ToString * dgvRow.Cells(6).Value.ToString() }
Datagridview2.Rows.Add(row3)
Next
End Sub
Don't get the error...
Greetings Andi