Subtract number for each row from datagridview1 to datagridview2 and display to answer to datagridview3
.NET (Core and Framework)
2
Posts
2
Posters
0
Views
1
Watching
-
Hello po. Ito po yung current code ko. Please help po. TIA
Dim dt As New DataTable() dt.Columns.Add("Name") dt.Columns.Add("Count") Dim manpower1 As Integer Dim present1 As Integer For Each row As DataGridViewRow In manpower.Rows dt.Rows.Add(row.Cells(1).Value) Next For Each row1 As DataGridViewRow In present.Rows present1 = (row1.Cells(1).Value) dt.Rows.Add(manpower1 - present1) Next For Each row2 As DataGridViewRow In manpower.Rows dt.Rows.Add(manpower1 - present1) Next absent.DataSource = dt
-
Hello po. Ito po yung current code ko. Please help po. TIA
Dim dt As New DataTable() dt.Columns.Add("Name") dt.Columns.Add("Count") Dim manpower1 As Integer Dim present1 As Integer For Each row As DataGridViewRow In manpower.Rows dt.Rows.Add(row.Cells(1).Value) Next For Each row1 As DataGridViewRow In present.Rows present1 = (row1.Cells(1).Value) dt.Rows.Add(manpower1 - present1) Next For Each row2 As DataGridViewRow In manpower.Rows dt.Rows.Add(manpower1 - present1) Next absent.DataSource = dt
You are adding 3 sets of rows to your datatable instead of just 1. Try something like:
For Int row = manpower.RowCount
manpower1 = manpower.Rows(row).Columns(1).Value
present1 = present.Rows(row).Columns(1).Value
dt.Rows.Add(manpower1 - present1)
Next
absent.DataSource = dt