DataGridView columns

P

Paul Cheetham

Hi,

I have a DataGridView control, and I am using it's datasource property
to assign a datatable to it at runtime.
The datatable has some columns in it that I don't want to be visible.

With the DataGrid control in .Net 1, each Column had a property that
allowed it to be bound to a column in a datatable, so I could define the
columns of the grid, and which columns they related to in its
datasource, and they were all that would display.

Is there an equivalent in the DataGridView, or another way to achieve this?


Thanks.


Paul Cheetham
 
K

Kevin Spencer

You can either set their Visible properties to false, or remove them from
the DataGridView Columns Collection.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

The man who questions opinions is wise.
The man who quarrels with facts is a fool.
 
P

Paul Cheetham

So I can only do it after I have bound a datasource to the Dategridview?
Which presumably means that every time I re-load the data, I have to
remove the columns I don't want.

It seems a much less elegant way of doing it than the method the
Datagrid used.


Paul
 
K

Kevin Spencer

You only have to do it the first time you create the DataGridView. After
that, you can update it, add and remove rows, etc, without modification.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

The man who questions opinions is wise.
The man who quarrels with facts is a fool.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top