How to fix the AutoGenerateColumns<fbb45e6a-0b2f-4001-b813-60bcb7e9858c@1g2000hsl.googlegroups.com>


A

aaron leamington

I was also being driven crazy by this problem of reappearing columns in the designer even though I had sub classed the DataGridView control and set base.AutoGenerateColumns = false in the constructor.

After analysing ones that seemed to be OK vs ones that were having the problem, I found the corruption to be in the resx file for the datagridview. At the bottom of the file (open with an xml editor), there will be a number of <metadata > elements. Keep the one for your binding source and delete all the ones for the columns.

Now regenerate your solution and then try re-opening your designer. If you are as lucky as me, then your problem should have disappeared.

Good Luck.
 
Ad

Advertisements

R

Ranny Meier

There were a bunch of these "UserAddedColumn" metadata in the .resx file for that form. Once those were gone the DGV AutoGenerateColumn problem quit.

<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>




aaron leamington wrote:

How to fix the AutoGenerateColumns
28-May-08

I was also being driven crazy by this problem of reappearing columns in the designer even though I had sub classed the DataGridView control and set base.AutoGenerateColumns = false in the constructor.

After analysing ones that seemed to be OK vs ones that were having the problem, I found the corruption to be in the resx file for the datagridview. At the bottom of the file (open with an xml editor), there will be a number of <metadata > elements. Keep the one for your binding source and delete all the ones for the columns.

Now regenerate your solution and then try re-opening your designer. If you are as lucky as me, then your problem should have disappeared.

Good Luck.

Previous Posts In This Thread:

Re: Why is DataGridView.AutogenerateColumns not exposed in designer
On Wed, 30 Jan 2008 08:37:59 -0800 (PST), Crazy Cat


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
AutoGenerateColumns = False in the constructor.

Why is DataGridView.AutogenerateColumns not exposed in designer
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!

Thanks,

Re: Why is DataGridView.AutogenerateColumns not exposed in designer

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

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

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.

How to fix the AutoGenerateColumns
I was also being driven crazy by this problem of reappearing columns in the designer even though I had sub classed the DataGridView control and set base.AutoGenerateColumns = false in the constructor.

After analysing ones that seemed to be OK vs ones that were having the problem, I found the corruption to be in the resx file for the datagridview. At the bottom of the file (open with an xml editor), there will be a number of <metadata > elements. Keep the one for your binding source and delete all the ones for the columns.

Now regenerate your solution and then try re-opening your designer. If you are as lucky as me, then your problem should have disappeared.

Good Luck.

Why is DataGridView.AutogenerateColumns not exposed in designer
When we use the DGV bindingsource as the datasource for another bindingsource; then "not setting the datasource" at design time does not seem to be an option.

The best solution would be simply for the VS Designer to not autogenerate columns when this property is set to false. That seems simple to me. What don't I know?


Submitted via EggHeadCafe - Software Developer Portal of Choice
Generics: Constraints, IComparable, and IEnumerable
http://www.eggheadcafe.com/tutorials/aspnet/7c431a9f-8cbd-4f5c-8397-9c412a25b257/generics-constraints-ic.aspx
 

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