Back to Devexpress

BaseView.SaveLayoutToStream(Stream) Method

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-baseview-dot-savelayouttostream-x28-system-dot-io-dot-stream-x29.md

latest4.4 KB
Original Source

BaseView.SaveLayoutToStream(Stream) Method

Saves a View’s layout to a specific stream.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
public void SaveLayoutToStream(
    Stream stream
)
vb
Public Sub SaveLayoutToStream(
    stream As Stream
)

Parameters

NameTypeDescription
streamStream

A Stream descendant to which a View’s layout is written.

|

Remarks

Use the SaveLayoutToStream method to write a View’s layout to a stream. You can then read saved settings using the BaseView.RestoreLayoutFromStream method.

The ColumnView.OptionsLayout property controls which settings should be saved to the stream.

Important

The Document Manager identifies its child documents by names of controls hosted within these documents. Thus, it is recommended that you set unique names for these controls. Failure to comply with this recommendation will result in an exception for certain scenarios (e.g., saving and restoring a View layout by using the SaveLayoutToStream method).

Tip

You can utilize the Persistence Behavior or Workspace Manager component to save and restore layouts for all supported DevExpress controls at once.

Example

The following sample code saves the layout of the active View to a memory stream and then restores it. The BaseView.SaveLayoutToStream and BaseView.RestoreLayoutFromStream methods are used for this purpose.

csharp
System.IO.Stream str;
//...
// Create and save 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);

// ...
// Load the view's layout from a previously saved memory stream.
gridControl1.FocusedView.RestoreLayoutFromStream(str);
str.Seek(0, System.IO.SeekOrigin.Begin);
vb
Dim str As System.IO.Stream
'...
' Create and save 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)

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

See Also

RestoreLayoutFromStream

SaveLayoutToRegistry

SaveLayoutToXml

OptionsLayout

LayoutUpgrade

Save and Restore Grid Layout

Save and Restore Layouts of DevExpress controls

BaseView Class

BaseView Members

DevExpress.XtraGrid.Views.Base Namespace