I have a C# app where on my grid I add a bunch of columns dynamically from a database table. When the user updates this table I need to show the updated columns on the grid that uses the data. In my code below I loop through all the columns and delete the unbound ones.
However, they don't seem to be getting deleted. If I loop through again right after running the code below, it shows that they are still there! Plus, when the grid initializes again and goes to add the dynamic columns, I get told that the keys already exist.
Besides using the key, I've also tried the index. That did not work either. I've also tried passing the column object in directly.
Hopefully I am missing something simple here. Really appreciate the help.
foreach (UltraGridBand band in myGrid.DisplayLayout.Bands) { foreach (UltraGridColumn column in band.Columns) { myGrid.DisplayLayout.Bands[0].Columns.Remove(column.Key); } } }
In the grid's initialize layout first clear your Unbound columns and add it if needed.
Ideally should look like this..
Grid.DisplayLayout.Bands(0).Columns.ClearUnbound()