After binding the Data grid View to a datasource I need to change the column headers on 12 columns to user friendly values and make them read only.
Grid.Columns["columnname"].HeaderText = "Column Name";
Grid.Columns["Client"].ReadOnly = true;
When the Grid contains a large dataset (10,000+ records) there is a noticeable delay in the time it takes to refresh the grid. Retrieving the data takes sub-second time. The function that changes the 12 column headertext values and setting ReadOnly = True on several others takes roughly 3-4 times that long and spikes the CPU usage to 100% for 1 core.
On Small datasets the renaming process takes negligible time, so it is clearly dependent on the size of the data set.
All column/Row Auto-sizing properties have been turned off. The DataGridView.SuspendLayout() function saves 10 milliseconds. DoubleBuffering saved 10 milliseconds.
What could the code be doing in the background that is taking so much processor power? Is it redrawing the whole grid each time those properties are changed? Is there a way to only have that redraw happen once?