Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 802
Baruch Avatar asked Oct 25 '25 14:10

Baruch


1 Answers

Are you looking for ColumnCount?

like image 191
dlev Avatar answered Oct 27 '25 10:10

dlev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!