Why it double Add new row for dr = dt.NewRow()

kank

Active member
Joined
Dec 12, 2011
Messages
26
Programming Experience
Beginner
Hi,

I use dr = dt.NewRow() to add new row data on datagridview. I click at new row to add data, it double added 2 row at the datagridview. Why???? I am confuse,please help.

VB.NET:
   Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        Dim r As Integer
        Dim dr As DataRow
        dt = ds.Tables("Login")
        r = e.RowIndex
        MessageBox.Show(dt.Rows.Count)
        MessageBox.Show(r)
        If r < dt.Rows.Count Then
            dt.Rows(r).Item(6) = uid
            dt.Rows(r).Item(7) = curr
        Else
            
            dr = dt.NewRow()
            dt.Rows.Add(dr)
            dt.Rows(r).Item(4) = uid
            dt.Rows(r).Item(5) = curr[ATTACH]3127.vB[/ATTACH]
           

        End If

    End Sub

I have attached the result of this too. :bawling: Please help, thanks!!
 
Back
Top