Version

SaveAsBinary(Stream,Boolean) Method

Saves properties, structure, and data information to a binary stream.
Syntax
'Declaration
 
Public Overloads Sub SaveAsBinary( _
   ByVal stream As Stream, _
   ByVal includeData As Boolean _
) 
public void SaveAsBinary( 
   Stream stream,
   bool includeData
)

Parameters

stream
Stream containing the serialized UltraDataSource information
includeData
Determines whether that data is saved along with the data structure.
Remarks

The SaveAsBinary method is used in conjunction with the LoadFromBinary(Stream,Boolean) method to persist the property settings and layout of the ultraDataSource.

Example
Following code demonstrates how Save and Load methods of the UltraDataSource can be used to save data to a stream and retrieved later on. In following code data is saved to a memory stream in Save button's Click event handler. That data is retrieved from the stream in Load button's Click handler. For demonstration purposes, in Clear button's event handler data is cleared from the data source.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinDataSource


    Dim memoryStream As System.IO.MemoryStream = Nothing

    Private Sub SaveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles saveButton.Click
        Me.memoryStream = New System.IO.MemoryStream()

        ' Save data to a stream. Pass in true for the includeData parameter
        ' to save data and not just the structure.
        Me.ultraDataSource1.SaveAsBinary(Me.memoryStream, True)
    End Sub

    Private Sub ClearDataSource_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles clearDataSource.Click
        Me.UltraDataSource1.Rows.Clear()
    End Sub

    Private Sub LoadButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles loadButton.Click
        ' Make sure the Position is set to a location where the saved data
        ' begins.
        Me.MemoryStream.Position = 0

        ' Retrieve previously saved data from the stream. Pass in true for 
        ' the includeData parameter to save data and not just the structure.
        Me.UltraDataSource1.LoadFromBinary(Me.MemoryStream, True)
    End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinDataSource;
using System.Diagnostics;


		System.IO.MemoryStream memoryStream = null;

		private void saveButton_Click(object sender, System.EventArgs e)
		{
			this.memoryStream = new System.IO.MemoryStream( );

			// Save data to a stream. Pass in true for the includeData parameter
			// to save data and not just the structure.
			this.ultraDataSource1.SaveAsBinary( this.memoryStream, true );
		}

		private void clearDataSource_Click(object sender, System.EventArgs e)
		{
            this.ultraDataSource1.Rows.Clear( );		
		}

		private void loadButton_Click(object sender, System.EventArgs e)
		{
			// Make sure the Position is set to a location where the saved data
			// begins.
            this.memoryStream.Position = 0;			

			// Retrieve previously saved data from the stream. Pass in true for 
			// the includeData parameter to save data and not just the structure.
			this.ultraDataSource1.LoadFromBinary( this.memoryStream, true );
		}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also