2017-04-10 33 views
-1

我目前工作的一個索引的工具,我算舊圖標映射所有出現新的圖標(許多老一新)Vb.net插入行的DataGridView刪除了該行

我都算事件和得到這樣一個結果:

W0001_S32G2 1 O001_S32G1 3 - 
W0001_S32G2 1 O001_S32G1 6 - 

每一樣新的圖標後,我想添加一個合計行:

W0001_S32G2 1 O001_S32G1 3 - 
W0001_S32G2 1 O001_S32G1 6 - 
    -  -  -  - 10 

哪裏算舊圖標新圖標出現的次數(一次) 我的計數是目前正確的,但是當我給定索引處添加排它,而不是實際刪除行之間插入它的當前數據:從我看到網上由於

For Each indi As String In cleanList 
    Dim indexes As New List(Of Integer) 
    Dim totnew As Integer = 0 
    Dim totold As Integer = 0 
    For Each row As DataGridViewRow In DataGridView2.Rows 
     If row.Cells("Name").Value = indi Then 
      totnew = totnew + CInt(row.Cells("Nombre").Value) 
      totold = totold + CInt(row.Cells("Nombre1").Value) 
      indexes.Add(row.Index) 
     End If 
    Next 
    DataGridView2.Rows.Insert(indexes.Last, New Object() {"-", "-", "-", "-", totnew + totold}) 
Next 

回答

0

,它不可能加入字裏行間我所有的數據複製到一個列表,然後用加入我的新線在列表中解決了這個問題:

EndList.Insert(incre + i, MyHiera) 

我再複製列表回的DataGridView