Now lets look at a simple code snippet showing how to preserve the appearance settings and discard the data of the chart when you serialize the control:
C# |
Copy Code
|
---|---|
NControlSerializer serializer = chartControl.Serializer; NChart chart = chartControl.Charts[0]; // save the chart to file MemoryStream memoryStream = new MemoryStream(); serializer.SaveToFile(chart, "c:\\temp\\chart.bin", PersistencyFormat.CustomBinary, new NDataSerializationFilter()); // load the chart from file NChart chart2 = (NChart)serializer.LoadFromFile(typeof(NChart), "c:\\temp\\chart.bin", PersistencyFormat.CustomBinary, new NDataSerializationFilter()); |
Visual Basic |
Copy Code
|
---|---|
Dim serializer As NControlSerializer = chartControl.Serializer Dim chart As NChart = chartControl.Charts(0) ' save the chart to file serializer.SaveToFile(chart, "c:\\temp\\chart.bin", PersistencyFormat.CustomBinary, New NDataSerializationFilter()) ' load the chart from file Dim chart2 As NChart = CType(serializer.LoadFromFile(GetType(NChart), "c:\\temp\\chart.bin", PersistencyFormat.CustomBinary, New NDataSerializationFilter()), NChart) |