This question is locked. New answers and comments are not allowed.
I thought I'd post a few changes I've made to the RadGridViewSettings.cs file that is part of the "Save and Load grid settings" example. The LoadState() function doesn't allow binding as the columns are cleared. I'm sure this could be added, but all I needed was the width. Here's my modified code that finds existing columns instead of creating them. You must have the UniqueName field set for each column:
Also, in the SaveState() function, it seems the following change is needed to save the column width. In the LINQ query that declares the "cell" property, change the where clause from
to
| if (Settings.ColumnSettings.Count > 0) |
| { |
| //grid.AutoGenerateColumns = false; |
| //grid.Columns.Clear(); |
| //foreach (ColumnSetting setting in Settings.ColumnSettings) |
| //{ |
| // GridViewDataColumn column = new GridViewDataColumn(); |
| // column.UniqueName = setting.UniqueName; |
| // column.HeaderText = setting.HeaderText; |
| // if (setting.Width != null) |
| // { |
| // column.Width = new GridLength(setting.Width.Value); |
| // } |
| // grid.Columns.Add(column); |
| //} |
| foreach (ColumnSetting setting in Settings.ColumnSettings) |
| { |
| GridViewDataColumn column = (GridViewDataColumn)grid.Columns[setting.UniqueName]; |
| if (setting.Width != null) |
| { |
| column.Width = new GridLength(setting.Width.Value); |
| } |
| } |
| } |
Also, in the SaveState() function, it seems the following change is needed to save the column width. In the LINQ query that declares the "cell" property, change the where clause from
| where c.Column.UniqueName == setting.PropertyName |
to
| where c.Column.UniqueName == setting.UniqueName |