DataFilter for WinForms | ComponentOne
Data Filters / XML Serialization/Deserialization
In This Topic
    XML Serialization/Deserialization
    In This Topic

    The DataFilter control supports serialization through SaveFilterExpression and LoadFilterExpression methods of the C1DataFilter class. The SaveFilterExpression method saves the current filter expressions from C1.Win.DataFilter.C1DataFilter.Filters collection to an XML file. The LoadFilterExpression method loads the saved filter expressions from an XML file.

    The following GIF demonstrates serialization and deserialization support in the DataFilter control.

    Serialization

    The following code shows an example of saving filter expressions to an XML file:

    //Saves the current filter expressions to an xml file
    c1DataFilter1.SaveFilterExpression("SavedFilters.xml");
    MessageBox.Show("Filter state saved.");
    
    //Saves the current filter expressions to an xml file
    c1DataFilter1.SaveFilterExpression("SavedFilters.xml");
    MessageBox.Show("Filter state saved.");
    

    The following code shows an example of loading filter expressions from an XML file:

    'Loads the current filter expressions from an xml file
    c1DataFilter1.LoadFilterExpression("SavedFilters.xml")
    MessageBox.Show("Loaded saved Filter state.")
    
    //Loads the current filter expressions from an xml file
    c1DataFilter1.LoadFilterExpression("SavedFilters.xml");
    MessageBox.Show("Loaded saved Filter state.");