0

Instead of adding data in the new blank row, it creates a blank row and adds new data in the add new '*'. Like this:

enter image description here

Vdroptable as the datagridview Here's the code of delete row

If Vdroptable.Rows(j).Cells(0).Value.ToString = "A1B1" Then
    Vdroptable.Rows(j).Selected = True
    For Each row As DataGridViewRow In Vdroptable.SelectedRows
        Vdroptable.Rows.Remove(row)
    Next

Code of adding row

If SpanName.Text = "A1B1" Then
    iVdroptable.Rows.Add()
            Vdroptable.Rows(x).Cells(0).Value = "A1B1"
            Vdroptable.Rows(x).Cells(1).Value = "A1"
            Vdroptable.Rows(x).Cells(2).Value = "B1"
isshi
  • 1
  • 4
  • I have two buttons, input and delete. Whenever I delete for eg. 'A1B1' then add it again... i always come up with the picture above – isshi Oct 22 '16 at 13:05
  • Possible duplicate of [How to add a new row to datagridview programmatically](http://stackoverflow.com/questions/10063770/how-to-add-a-new-row-to-datagridview-programmatically) – Andrew Morton Oct 22 '16 at 13:17
  • I actually assume that there's a question resembles this but I think that possible duplicate did not answer my question – isshi Oct 22 '16 at 15:51

1 Answers1

0

You have no parameter inside the Add() therefore it is empty. You need to pass values to it, like this:

iVdropTable.Rows.Add("aaa", "bbb", "ccc")

This should fix the inserting part, which is the question about. If you want to solve the deleting part here as well, you will need to elaborate the problem you have.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
  • but the table is incrementing... after the code `iVdroptable.Rows.Add()` I added: `Vdroptable.Rows(x).Cells(0).Value = "A1B1" Vdroptable.Rows(x).Cells(1).Value = "A1" Vdroptable.Rows(x).Cells(2).Value = "B1"` – isshi Oct 22 '16 at 14:48
  • @isshi, can you show us what we the exact input and what were the exact operations you did, what did you expect and what did you get instead. – Lajos Arpad Oct 22 '16 at 15:10
  • I already posted the result (in the photo attached in my question) – isshi Oct 22 '16 at 15:16