下面的示例演示了如何把图表保存到内存流,然后恢复。

C#CopyCode image复制代码
using System.IO;
// ...

Stream stream = new MemoryStream();
// ...

// Save the chart.
stream.Seek(0, System.IO.SeekOrigin.Begin);
chartControl1.SaveToStream(stream);

// Load the chart.
stream.Seek(0, System.IO.SeekOrigin.Begin);
chartControl1.LoadFromStream(stream);
Visual BasicCopyCode image复制代码
Imports System.IO
' ...

Dim stream As System.IO.Stream
stream = New System.IO.MemoryStream()
' ...

' Save the chart.
stream.Seek(0, System.IO.SeekOrigin.Begin)
ChartControl1.SaveToStream(stream)

' Load the chart.
stream.Seek(0, System.IO.SeekOrigin.Begin)
ChartControl1.LoadFromStream(stream)