Posted 9 August 2019, 1:58 am EST
Hello Michael,
This exception occurs because each element of CellStyleCollection is readonly.
When loading grid from xml document, it loads the data as well as the formatting information.
Although if you want to just copy the style from one grid to another not the data, you create a XML file of OldGrid using WriteXml method and Load that XML file into another grid using ReadXml method and then change the datasource of the NewGrid.(Style will be retained and data Will be changed). This way all the styling set through Styles property of OldGrid gets copied to the NewGrid.
Another way of doing this is, you need to use the MergeWith method of CellStyle class and add all the styles one by one which has been set to the OldGrid specifically.
For example :
//this copies all the styling info set to the normal cells of the FlexGrid
newGrid.Styles.Normal.MergeWith(oldGrid.Styles.Normal);
//this copies all the styling info set to column1 of Flexgrid
newGrid.Cols[1].Style.MergeWith(oldGrid.Cols[1].Style);
Thanks and Regards,
Prabhat Sharma.