下面的示例演示了如何把活动视图的布局 (在 XtraGrid 控件中) 保存到流中,然后恢复它。

C#CopyCode image复制代码
System.IO.Stream str;
//...
// creating and saving the view's layout to a new memory stream
str = new System.IO.MemoryStream();
gridControl1.FocusedView.SaveLayoutToStream(str);
str.Seek(0, System.IO.SeekOrigin.Begin);

// ...
// loading the view's layout from a previously saved memory stream
gridControl1.FocusedView.RestoreLayoutFromStream(str);
str.Seek(0, System.IO.SeekOrigin.Begin);
Visual BasicCopyCode image复制代码
Dim str As System.IO.Stream
'...
' creating and saving the view's layout to a new memory stream
str = New System.IO.MemoryStream()
GridControl1.FocusedView.SaveLayoutToStream(str)
str.Seek(0, System.IO.SeekOrigin.Begin)

' ...
' loading the view's layout from a previously saved memory stream
GridControl1.FocusedView.RestoreLayoutFromStream(str)
str.Seek(0, System.IO.SeekOrigin.Begin)