下面的示例代码把活动视图的布局保存到内存流中,然后从中恢复。 为了达到此目的,使用了BaseView.SaveLayoutToStreamBaseView.RestoreLayoutFromStream 方法。

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

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

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