This is a migrated thread and some comments may be shown as answers.

Save Colors in Layout

3 Answers 65 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ahmad
Top achievements
Rank 1
ahmad asked on 10 Jan 2016, 07:02 AM

I save RadGridView layout in SQL using the following code:

string name = Microsoft.VisualBasic.Interaction.InputBox("Please insert the layout name:", " ");
using (MemoryStream ms = new MemoryStream())
{
    var lay = new Rahat.Layout();
    lay.User_Id = 123;
    lay.Title = name;
    #region lay.Layout
    grid.SaveLayout(ms);
    var sw = new StreamWriter(ms);
    sw.Flush();
    ms.Position = 0;
    var sr = new StreamReader(ms);
    var myStr = sr.ReadToEnd();
    lay.Layout = myStr;
    #endregion
    _dbRahat.Layouts.InsertOnSubmit(lay);
    _dbRahat.SubmitChanges();
}

and load the layout using the following code:

var lay = _dbRahat.Layouts.First(l => l.Id.ToString() == cmbPreset.SelectedValue.ToString());
 
byte[] byteArray = Encoding.UTF8.GetBytes(lay.Layout);
var stream = new MemoryStream(byteArray);
grid.LoadLayout(stream);
 
FillGrid();

The problem is that the grid colors (header cell colors, data cell colors) are not saved and loaded with SaveLayout() and LoadLayout() methods. How can I solve this problem?

Thank you

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 13 Jan 2016, 01:53 PM
Hello Ahmad,

Thank you for writing.

The Save/Load functionality only saves logical layout information (like columns position and size). It does not save any styling properties. In this case, you can save the colors as application settings: c# - Save Settings in NET Winforms Application - Stack Overflow

I hope this helps.

Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
ahmad
Top achievements
Rank 1
answered on 14 Jan 2016, 05:43 AM
If I change cell colors and then load layout then colors are disappeared? How can I prevent from this?
0
Dimitar
Telerik team
answered on 18 Jan 2016, 12:22 PM
Hi Ahmad,

Thank you for writing.

Please note that all rows and columns are recreated when the layout is loaded and if you are using the Style property to change the grid appearance the styles will be reset. In this case, you should either set the styles after the layout is loaded or use the formatting events to style the grid.

I hope this will be useful. 

Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
ahmad
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
ahmad
Top achievements
Rank 1
Share this question
or