Back to Devexpress

How to: Save a control's layout to a stream

windowsforms-1877-common-features-save-and-restore-layouts-how-to-save-a-controls-layout-to-a-stream.md

latest948 B
Original Source

How to: Save a control's layout to a stream

  • Oct 29, 2020

The example below demonstrates a way of saving an active view’s layout (in XtraGrid) to a stream and then restoring it.

csharp
System.IO.Stream str;
//...
// Save the layout to a new memory stream.
str = new System.IO.MemoryStream();
gridControl1.FocusedView.SaveLayoutToStream(str);
str.Seek(0, System.IO.SeekOrigin.Begin);

// ...
// Load the saved layout.
gridControl1.FocusedView.RestoreLayoutFromStream(str);
str.Seek(0, System.IO.SeekOrigin.Begin);
vb
Dim str As System.IO.Stream
'...
' Save the layout to a new memory stream.
str = New System.IO.MemoryStream()
GridControl1.FocusedView.SaveLayoutToStream(str)
str.Seek(0, System.IO.SeekOrigin.Begin)

' ...
' Load the saved layout.
GridControl1.FocusedView.RestoreLayoutFromStream(str)
str.Seek(0, System.IO.SeekOrigin.Begin)