views:

31

answers:

1

DataGridView inserting an extra row every time I populate with data. The row appears even if I only fill the column headers. This is causing problems when I try to get values of each cell.

Is there a way to avoid this perhaps in properties?

Thanks in advance for any suggestions.

A: 

It isn't very clear what your exact issue is.

The only behaviour I can think of that matches what you are describing is the AllowUserToAddRows property of the DataGridView. This provides a row at the bottom of the grid populated with empty, editable controls.

If you set the property to false, do you get the behaviour that you want?

Another option is to ignore this row when doing any other processing - the new row will have the property of IsNewRow set to true:

if (!dataGridView1.Row[i].IsNewRow)
{ 
    //This is not the new row
}

(Sorry about the C# above - my vb.Net is very rusty at the moment)

David Hall