Back to Devexpress

BaseView.RestoreLayoutFromStream(Stream) Method

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

latest4.4 KB
Original Source

BaseView.RestoreLayoutFromStream(Stream) Method

SECURITY-RELATED CONSIDERATIONS

Deserializing layout settings from untrusted resources may create security issues. Review the following help topic for additional information: Safe Deserialization.

Restores a View’s layout from the specified stream.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

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

Parameters

NameTypeDescription
streamStream

A Stream descendant from which View settings are read.

|

Remarks

Use the RestoreLayoutFromStream method to load the View’s layout from the stream to which the layout was saved via the BaseView.SaveLayoutToStream method. If the specified stream is empty or null ( Nothing in Visual Basic), an exception is raised.

The ColumnView.OptionsLayout property controls which settings should be restored from the stream.

Note

When restoring a layout during a form load (for instance, in your Form.Load event handler), you may need to call the GridControl.ForceInitialize method prior to the layout restoration. See this method to learn more.

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

SaveLayoutToStream

RestoreLayoutFromRegistry

RestoreLayoutFromXml

OptionsLayout

LayoutUpgrade

Save and Restore Grid Layout

Save and Restore Layouts of DevExpress controls

BaseView Class

BaseView Members

DevExpress.XtraGrid.Views.Base Namespace