)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to serialize schema settings while using custom engine in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: September 26, 2016 |
Last Revised Date: December 24, 2019

Serialization

In order to serialize the grid when the grid is defined with the custom engine, override the CreateFormXml and WriteXml method in CustomEngine. The XMLSerializer can be defined with the CustomEngine that you created for grid.

C#

public class CustomEngine: GridEngine 
{ 
    public override ChildTable CreateChildTable(Element parent) 
    { 
        return new GroupingChildTable (parent); 
    } 
   /// <summary>
   /// Creates a valid stream for custom engine
   /// </summary>
    public override GridEngine CreateFromXml(XmlReader xr) 
    { 
        XmlSerializer serializer = new XmlSerializer(typeof(CustomEngine)); 
        object obj = serializer.Deserialize(xr); 
        xr.Close(); 
        return obj as CustomEngine; 
    } 
 
    /// <summary>
    /// Saves the engine changes to an XML stream.
    /// </summary>
    public override void WriteXml(XmlWriter xw) 
    { 
        XmlSerializer serializer = new XmlSerializer(typeof(CustomEngine)); 
        serializer.Serialize(xw, this); 
    } 
}

 

VB

Public Class CustomEngine
        Inherits GridEngine
        Public Overrides Function CreateChildTable(ByVal parent As Element) As ChildTable
                Return New GroupingChildTable(parent)
        End Function
        
        ''' <summary>
        ''' Creates a valid stream for custom engine
        ''' </summary>
        Public Overrides Function CreateFromXml(ByVal xr As XmlReader) As GridEngine
                Dim serializer As New XmlSerializer(GetType(CustomEngine))
                Dim obj As Object = serializer.Deserialize(xr)
                xr.Close()
                Return TryCast(obj, CustomEngine)
        End Function
 
        ''' <summary>
        ''' Saves the engine changes to an XML stream.
        ''' </summary>
        Public Overrides Sub WriteXml(ByVal xw As XmlWriter)
                Dim serializer As New XmlSerializer(GetType(CustomEngine))
                serializer.Serialize(xw, Me)
        End Sub
End Class

Samples:

C#: Custom_Engine_Serialization

VB: Custom_Engine_Serialization

Reference link: https://help.syncfusion.com/windowsforms/classic/gridgroupingcontrol/serialization

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon