After the reflection, you can see the below code,
public virtual int Add()
{
if (this.DataGridView.DataSource != null)
{
throw new InvalidOperationException(SR.GetString("DataGridViewRowCollection_AddUnboundRow"));
}
if (this.DataGridView.NoDimensionChangeAllowed)
{
throw new InvalidOperationException(SR.GetString("DataGridView_ForbiddenOperationInEventHandler"));
}
return this.AddInternal(false, null);
}
if you set the property of datasource to be data
and when you add rows and columns, an error occurs. So, you need to add binding source and use it to connect the datatable with gridview. Thus, you can realize your task.
people who want to create data grid view can go to this page http://www.e-iceblue.com/Knowledgebase/Spire.PDF/Demos/Grid.html#twoj_fragment1-1