Guys, I want to count the rows on my datagrid but counting -1.
for example if i had 1 row in my datagrid i want label1 to display 0
I'm using the code below, it counts correct but i cant adapt it to count -1? am I missing something simple?
int count = 0; foreach (DataGridViewRow row in vehDataGridView.Rows)
{
if (row.IsNewRow) break;
object obj = row.Cells;
if (obj != null && !DBNull.Value.Equals(obj) )count++;
{
label1.Text = count.ToString();
}
}

1 answers
Well, the number of rows in the DGV excluding the 'new row' at the bottom is simply vehDataGridView.Rows.Count -1.
So this should work:
answered one year ago by:
17279
690
Nice one vulpes, just how i wanted it to work.