all groups > dotnet windows forms > january 2008 >
You're in the

dotnet windows forms

group:

Why is DataGridView.AutogenerateColumns not exposed in designer


Why is DataGridView.AutogenerateColumns not exposed in designer Crazy Cat
1/30/2008 8:37:59 AM
dotnet windows forms:
Does anyone know why this is not exposed in the designer?

Is it just me or is this a really stupid oversight?

I turn it on in code, but that doesn't prevent the designer from every
once in a while autogenerating columns on my datagridview. I can't
seem to predict when this'll happen -- for example, I've got my
datagridview's datasource set to a bindingsource -- I clear out the
unnecessary colums in the datagridview and start the application. All
is fine. However, on subsequent restarts, sometime I'll see that
columns have been autogenerated in the designer, even though in the
particular edit session, I never changed the datasource, or any
aspects of the bindingsource.

How to stop this -- it is ANNOYING!

Re: Why is DataGridView.AutogenerateColumns not exposed in designer Jack Jackson
1/30/2008 10:40:38 AM
On Wed, 30 Jan 2008 08:37:59 -0800 (PST), Crazy Cat
[quoted text, click to view]

I have run into the same problem. I asked about this here a few
months ago but never received a response.

What I finally did was to create a subclass of DataGridView and set
Re: Why is DataGridView.AutogenerateColumns not exposed in designer Crazy Cat
1/30/2008 12:03:30 PM
[quoted text, click to view]

Thanks for your response Jack.

I tried this and yet it is still autogenerating the columns. It must
be something I'm doing.

I looked at my code and the only thing I can put it down to is that I
dynamically set the datasource
in the code, but I set autogeneratecolumns to false in the constructor
of the derived class and for
good measure in the grid. In design view I deleted the extraneous
columns, started the application
and all was good. As soon as I stopped debugging I notice that
magically the columns have been regenerated
in design mode.
Re: Why is DataGridView.AutogenerateColumns not exposed in designer Crazy Cat
1/30/2008 12:11:37 PM
[quoted text, click to view]

OK, this time I'm pretty sure it's nothing I'm doing. In design mode I
delete the extraneous columns. When I close the form and reopen it in
the designer the columns have been autogenerated. This is only
happening on one datagrid in my application.

WHAT THE HELL?

Sign me,

FRUSTRATED
Re: Why is DataGridView.AutogenerateColumns not exposed in designer Crazy Cat
1/30/2008 12:30:00 PM
[quoted text, click to view]

OK, I found the solution --

Do not set DataSource and DataMember at design time -- set them at
runtime and all is fine.

Actually you might want to set them at design time to get the bindings
for your columns, but after setting the bindings CLEAR OUT THE
Datasource and Datamember properties and set them at runtime.
AddThis Social Bookmark Button