Sean Connolly

Hi.

Yesterday, timvw helped me to remove specific selected columns from a custom DataGridView which worked great (see here).

The form in question has two Combo Boxes and a DataGridView (which is programmed to set specific cell styles and to handle a Transposed DataSet/DataTable from a SQL server database (so the columns have to be added manually - limited to just over 65,000 columns instead of the normal limit of 655 columns).

When I close the form, everything is fine. My routine which reads the columns and converts them back into the correct SQL storage statement, performs correctly (does not use the DataSet/DataTable in this instance).

However, I realised I need to adjust the DataSet/DataTable too because if I wanted to browse to another table in the DataSet and come back again, I was going to lose all the changes I made because the DataSet wasn't updated.

I added the extra line of code to remove the columns from the DataSet/DataTable also and thought it would be OK, but the DataGridView is resetting the display to the plain DataGridView, thus losing all my programmed formatting!

Is there a way to stop the DataGridView losing the formatting when the DataSet is modified The DataSet/Table is the DataSource in this case.

Thanks in advance.

Sean



Re: Windows Forms Data Controls and Databinding Losing DataGridView style

Sean Connolly

I've fixed my problem.

I decided to go with unbound data mode and this has proved beneficial. I no longer need the routine that flips a Dataset to make the table transposed. Instead, because I have to populate the DataGridView myself, I am now able to read from the database and write the rows as columns instead.

Sean