I am working on a grid that shows a hierarchy. I build a dataset in code and populate it. I then bind it to the grid and there are 4 bands, which is correct.
Later, I need to repeat the process with different data. I set the DataSource of the grid to NOTHING, instantiate a new dataset and populate it. When I bind it to the grid the second time, there are now a bunch of extra bands. I've tried using the ResetDisplayLayout and Layouts.Clear methods on the grid, but nothing seems to get rid of these extra bands. The extra bands do not appear until I set the datasource on the grid. Any ideas on what could be happening? I am on version 13.2 of the grid.
I'm setting the DataSource on both the grid and the binding source to nothing, but something must be holding onto the original structure. I'll try your suggestion and dim up a new binding source and see what happens. Thanks!
Hi,
When you set the DataSource to null, are you talking about the DataSource of the grid, or the DataSource of the BindingSource?
From what you are describing, it sounds like the BindingSource is caching the data structure. So the simplest thing to do would be to create a new BindingSource with the new DataSet and then bind the grid to the new BindingSource.
I forgot to mention that I am using a binding source as the datasource for the grid. The binding source is pointing at the dataset. What is strange is that if I point the grid directly at the dataset, I get the proper number of bands every time, so the issue must lie in the binding source.