If you want to add or delete rows in a data gridview, you can use the following code:

  1. In your code, create a new object and name it DatagridView.
  2. Add the following lines of code to your program: DatagridView dgv = new DatagridView();
  3. In the constructor, set the data source to your data gridview: dgv.DataSource = myDataGridView;
  4. Add a row to the data gridview by calling dgv.AddRow(); and then call dgv.DeleteRow() to delete a row from the data gridview:
  5. Finally, close the DatagridView object by calling dgv.Close(): ..