Windows Develop Bookmark and Share   
 index > Windows Forms Designer > How to stop designer adding columns when i build the project
 

How to stop designer adding columns when i build the project

Could you please help me. Designer is adding columns to my datagridview when it is databound. I read that it may have something with AutoGenerateColumns property of DataGridView.

I tried this:

Manually write AutoGenerateColumns in designer.Didnt work

Thereis no propertynamed AutoGenerateColumnslisted in property gridin Properties panel. So i tried to inherit and change the browsable attribute. (Didnt work)

Please help me. I am in lack of time. And this makes Duplicate component names error. Please if you know how to. Tell me.

Adraw  Thursday, May 11, 2006 10:49 AM
I'm having the same problem. Did you ever find an answer. I'm about to pull my hair out!

If so please email me at rancedowner1234@hotmail.com

Thx
Rance Downer  Friday, May 26, 2006 9:08 PM
Adraw:

I stumbled on something that helped my situation and might help you too.

Do a "show all files" and then view the .resx file associated with the form and change the columns that are giving you the aberrant behavior... look for the column name followed by ".UserAddedColumn" Entry, and set it to False. In my case I actually went so far as to altogether delete the entries that say "[columnName].UserAddedColumn".

Apparently Visual Studio occasionaly corrupts this .resx during a rebuild, causing weird behavior like column duplication and column re-ordering/re-formatting. Deletiing the .resx entry (or changing it to false) seems to make Visual Studio think that the column was originally created by the designer when it was initially bound to the BindingSource object.

I actually called this one into Microsoft so hopefully they will fix it and put out in their next patch.

:0)
-Rance
Rance Downer  Saturday, May 27, 2006 12:26 AM

Rance / Adraw,

I was having the same problem. Rance's fix worked for me, but only if I follow this process exactly. It looks editing the Columns properties in the designer recreates the .UserAdded properties in the .resx file, so every time I make a change to one of the DataGridView columns in the designer, before building the project, I have to:

  1. Save the form.
  2. Open the .resx file
  3. Find the .UserAdded rows with the value "true" and change them to "false"
  4. Save the .resx file

As far as I can tell - if any of these .UserAdded rows are set to "true" when you compile/build the form, it'll add all the generated columns again. Sometimes this just looks ugly, a couple of times it's actually generated columns which conflicted with column names I already had and meant I could no longer open the form in the designer.

Just thought it might be of use to someone else on the forums having the same problem!

Dylan Beattie  Friday, October 20, 2006 11:22 AM

You can use google to search for other answers

Custom Search

More Threads

• Controls are not visable in .net code
• Property Grids
• DataColumn property in Component
• Draw Circle - urgent
• Adding dynamic panels to a panel in C#
• How to create table with merged cells
• error "Object type cannot be converted to target type." in task list
• How to display Phone Numbers in C#(Win Forms)?
• Custom MenuItem
• Form, Panel or UserControl