views:

30

answers:

2

I'm sure you know the problem, as soon as a BindingSource is connected to a DataGridView the DataGridView generates columns for each Property found in the Type of the BindingSource's DataSource and adds that crap to the Form.Designer.cs file.

We only use run time generated columns, the clutter in the designer file is just waste of code, so how can we stop this "feature" of the DataGridView in WinForms?

A: 

DataGridView.AutoGenerateColumns = false

DRapp
+1  A: 

Tell it to not auto-generate columns. http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.autogeneratecolumns.aspx

nportelli
Sorry, does not work actually. as soon as the BindingSource gets connected in the designer, the columns are generated and the designer file gets polluted.
BeowulfOF
What is the big deal really? No one looks at the designer file anyway. I think the columns are generated just for the designer. You could always take it off the form and manually add the datagridview to the form.
nportelli