How to fix a FieldChooser that is not updated while hiding columns using the HideCols property in WinForms GridGroupingControl?
Hide columns
The FieldChooser does not update the column values when some of the columns are hidden by using the HideCols property.
Figure 1: The columns hidden by using HideCols property
In the above image, the column [Product Name] is hidden by using the HideCols property but was not updated in the FieldChooser.
Figure 2: While hiding the columns using VisibleColumns collection
The above image displays the column [Product Name] hidden through the VisibleColumns collection and updated in the FieldChooser.
Solution:
By default, GridGroupingControl uses VisibleColumns collection to hide the columns. To hide the columns in the GridGroupingControl, you can remove the columns from the VisibleColumns collection, since the FieldChooser of the GridGroupingControl works based on the VisibleColumns collection. The TableModel.HideCols property does not remove the columns from the VisibleColumns collection, therefore the visibility of the columns is not updated in the FieldChooser.
//Hides column using the column name. this.gridGroupingControl1.TableDescriptor.VisibleColumns.Remove("ColumnName"); //Hides column by using the column index int columnIndex = 3; this.gridGroupingControl1.TableDescriptor.VisibleColumns.RemoveAt(columnIndex);