Baruch
Baruch

Reputation: 21508

Number of columns in a DataGridView

I must be missing something very obvious, since even searching for a couple of minutes returned nothing, but how can I get the number of columns in a DatagridView? The obvious DataGridView1.Columns.Count is wrong.

I am sorry if this has been asked a million times or has an obvious answer, but I just can't find it.

Edit: I just found at http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcolumncollection.aspx that the DataGridViewColumnCollection does have a property Count, so I used it and it worked. However, Intellisense does not suggest it. I had to manually enter it. Strange.

Upvotes: 4

Views: 10736

Answers (1)

dlev
dlev

Reputation: 48596

Are you looking for ColumnCount?

Upvotes: 3

Related Questions