Save and Restore column size and position

I want to store sfDataGrid column size & position and then load that next time.

Can you provide source code for this? We are using latest version 20.3460.0.47 in .Net framework 4.8 application.



 


1 Reply

DM Dhanasekar Mohanraj Syncfusion Team October 31, 2022 02:06 PM UTC

Your requirement to Store/Restore the size and order of the columns will be achievable by using the Serialization/Deserialization support of our SfDataGrid.

Store / Serialization:


using (var file = File.Create("DataGrid.xml"))
{
    SerializationOptions options = new SerializationOptions();

    options.SerializeColumns = false;

    this.sfDataGrid1.Serialize(file, options);
}



Restore / Deserialization:

using (var file = File.Open("DataGrid.xml", FileMode.Open))
{

    DeserializationOptions options = new DeserializationOptions();

    options.DeserializeColumns = false;

    this.sfDataGrid1.Deserialize(file, options);
}



For more information related to Serialization/Deserialization, please refer to the below user guide documentation link,

UG Link:

  1. https://help.syncfusion.com/windowsforms/datagrid/serializationdeserialization#serialization

  2. https://help.syncfusion.com/windowsforms/datagrid/serializationdeserialization#serialize-columns

  3. https://help.syncfusion.com/windowsforms/datagrid/serializationdeserialization#deserialize-columns

If we misunderstood your requirement, please provide more information regarding the requirement. This would help us proceed further.

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Loader.
Up arrow icon