'宣言 Public Overloads Sub Save( _ ByVal stream As Stream, _ ByVal propertyCategories As PropertyCategories _ )
public void Save( Stream stream, PropertyCategories propertyCategories )
このメソッドを呼び出すと、レイアウトがストリームに保存されます。ストリームを使用すれば、ディスク上のファイル、インターネット上の場所、メモリなどのさまざまな場所にレイアウト データを保存できます。
保存されたレイアウトを復元するには、Load メソッドを呼び出します。
256 (PropCatGeneral) を指定すると、UltraGridLayout オブジェクトの以下のプロパティ設定が保存されます。
|
|
|
複数の Layout カテゴリは、論理 OR を使用することで結合して保存ができます。
Clone および CopyFrom メソッドを呼び出すと、レイアウトの複製を作成できます。
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.UltraWinGrid Private LAYOUT_FILE_PATH As String = "c:\\test.layout" Private Sub Button90_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button90.Click ' Following code saves the ultraGrid1's layout to a file. Dim fs As System.IO.FileStream = Nothing Try ' Open a new file to save the layout to. fs = New System.IO.FileStream(LAYOUT_FILE_PATH, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None) Catch exc As Exception MessageBox.Show(Me, "Unable to create a new file " & LAYOUT_FILE_PATH & " for saving the layout. " & exc.Message, "Unable to create file", MessageBoxButtons.OK, MessageBoxIcon.Error) Return End Try ' Save the layout to the file. Me.UltraGrid1.DisplayLayout.Save(fs, PropertyCategories.All) ' Close the file. fs.Close() End Sub Private Sub Button91_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button91.Click ' Following code loads the saved layout from a file. Dim fs As System.IO.FileStream = Nothing Try ' Open the file where the layout has been saved before. fs = New System.IO.FileStream(LAYOUT_FILE_PATH, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read) Catch exc As Exception MessageBox.Show(Me, LAYOUT_FILE_PATH & " file not found. " & exc.Message, "Unable to open file", MessageBoxButtons.OK, MessageBoxIcon.Error) Return End Try ' Load the layout from the input stream by calling Load method. It is very important that you reset the ' Position of the file stream to where the layout data begins in case the file stream has ' been read from previously. fs.Position = 0 Me.UltraGrid1.DisplayLayout.Load(fs, PropertyCategories.All) ' Close the file fs.Close() End Sub
using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System.Diagnostics; private string LAYOUT_FILE_PATH = "c:\\test.layout"; private void button90_Click(object sender, System.EventArgs e) { // Following code saves the ultraGrid1's layout to a file. System.IO.FileStream fs = null; try { // Open a new file to save the layout to. fs = new System.IO.FileStream( LAYOUT_FILE_PATH, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None ); } catch ( Exception exc ) { MessageBox.Show( this, "Unable to create a new file " + LAYOUT_FILE_PATH + " for saving the layout. " + exc.Message, "Unable to create file", MessageBoxButtons.OK, MessageBoxIcon.Error ); return; } // Save the layout to the file. this.ultraGrid1.DisplayLayout.Save( fs, PropertyCategories.All ); // Close the file. fs.Close( ); } private void button91_Click(object sender, System.EventArgs e) { // Following code loads the saved layout from a file. System.IO.FileStream fs = null; try { // Open the file where the layout has been saved before. fs = new System.IO.FileStream( LAYOUT_FILE_PATH, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read ); } catch ( Exception exc ) { MessageBox.Show( this, LAYOUT_FILE_PATH + " file not found. " + exc.Message, "Unable to open file", MessageBoxButtons.OK, MessageBoxIcon.Error ); return; } // Load the layout from the input stream by calling Load method. It is very important that you reset the // Position of the file stream to where the layout data begins in case the file stream has // been read from previously. fs.Position = 0; this.ultraGrid1.DisplayLayout.Load( fs, PropertyCategories.All ); // Close the file fs.Close( ); }