Problem with DataGridView AutoGenerateColumns

Problem with DataGridView AutoGenerateColumns

Old forum URL: forums.lhotka.net/forums/t/3268.aspx


JonStonecash posted on Thursday, July 26, 2007

We are doing a CSLA 2.1.4 project.  We have a number of what I am calling "post" objects that have children objects and are linked to other "post" objects with many-to-many links.  These children and links are represented as editable child collections within the parent "post" object (we have separate collections of the many-to-many links for each parent "post" object). 

When we display one of these "post" objects in a Winform, we display the contents of each of these children collections in DataGridView controls.   We are using declarative binding sources that are populated at run time from CSLA editable child collections.  We have turned off the autogeneratecolumns and specified the specific columns from the binding source that we want to display.  This works. 

The problem that we have is that almost every time that we open the designer for the winform, it repopulates the column list with every column in the binding source.  We have to delete all of the columns and reset the declarative bindings.  Very uncool.

We have checked that the autogeneratecolumns is set to false.  We have locked the control.  We have torn our hair out (and none of us have hair to spare). 

I have seen some postings that suggest that you have to set the autogeneratecolumns flag before you set the databindings.  I have no idea of how to ensure the order of execution using declarative data binding.  We could move from declarative to programmatic data binding but that would be a fair amount of hacking that provides little benefit to the client.   Before we do that, I would like to see if any one else has found a solution to this problem.

BTW, we do have some Infragistic controls on the form but they are not directly involved with the controls that are misbehaving.

Jon Stonecash


triplea replied on Thursday, July 26, 2007

Could you maybe put the code that populates the datasource of your bindingsource around an: if(!this.DesignMode) ? Probably won't do the trick but maybe worth trying...

Copyright (c) Marimer LLC