Reputation: 75
I am using datagridview for a lot of things and I think it's a really strong data viewer tool. My Problem is, I am using this code:
for (int i = 0; i < dataGridView1.**Columns.Count** - 1; i++)
{
....
}
My question is, what is the difference between dataGridView1.Columns.Count
and dataGridView1.ColumnCount
.
They both return an integer that holds the number of columns in the dataGridView1
I searched only but couldn't find anything. I hope you guy help me.
Upvotes: 2
Views: 758
Reputation: 186833
If we consult reference source
we'll see no difference with respect of get
accessor:
public int ColumnCount
{
get
{
return this.Columns.Count;
}
set
{
...
}
}
It seems DataGridView.ColumnCount
property has been designed in order to provide set
in which we can add / remove columns
Upvotes: 2