Retrieving the amount of columns in a Data Grid.

  • Thread starter Thread starter Mitesh
  • Start date Start date
M

Mitesh

YourDataGrid.Columns

have all properties you can use.

if you want to know number of columns then

YourDataGrid.Columns.Count.

Mitesh.
 
-----Original Message-----

YourDataGrid.Columns

have all properties you can use.

if you want to know number of columns then

YourDataGrid.Columns.Count.

Mitesh.
.

Hello,

Thanks for your reply Mitesh, I have tried this and have
noticed that when you do this in ASP.NET it works but when
you do this witha datagrid in a windows application it
does not. It is the windows app I having trouble with. The
class DATAGRID.COLUMNS just doesn't exist as it does in
ASP.Net. Any ideas on a work around?

Regards,

James
 
If you are binding it to a DataTable, you can use DataTable.Columns.Count.
You are right though on the desktop, if you don't add the columns, it won't
show (or at least it's always given me trouble) unless you added the columns
in the designer beforehand.

Are you using a bound grid? If so, DataTable.Columns.Count will get it for
you.

HTH,

Bill
 
Back
Top