When you create layouts that you want to use in other solutions, you can save them as *.analysis files.
To save a layout
These steps assume that you have a created a viewer and have a data connection in place.
- In the design view of your Viewer form, from the Visual Studio toolbox, drag a Button onto your form.
- In the Properties grid, change the Text property of the button to Save Layout.
- Double-click the button to go to the code view of the form and create a Button Click event.
- Use code like the following to save the layout to your C drive in a file called MyNew.analysis.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Button Click event. Copy Code Dim myNewFile As New System.IO.FileInfo("C:\MyNew.analysis") Me.PivotView1.Write(myNewFile, GrapeCity.ActiveAnalysis.PersistSettings.Layout Or GrapeCity.ActiveAnalysis.PersistSettings.DataSource)
C# code. Paste INSIDE the Button Click event. Copy Code System.IO.FileInfo myNewFile = new System.IO.FileInfo(@"C:\MyNew.analysis"); this.pivotView1.Write(myNewFile, GrapeCity.ActiveAnalysis.PersistSettings.Layout | GrapeCity.ActiveAnalysis.PersistSettings.DataSource);
To load a saved layout
You need not have a data connection in place for these steps. The data connection is saved with the view.
- In the design view of your Viewer form, from the Visual Studio toolbox, drag a Button onto your form.
- In the Properties grid, change the Text property of the button to Load Layout.
- Double-click the button to go to the code view of the form and create a Button Click event.
- Use code like the following to save the layout to your C drive in a file called MyNew.analysis.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Button Click event. Copy Code Dim myNewFile As New System.IO.FileInfo("C:\MyNew.analysis") Me.PivotView1.Read(myNewFile, GrapeCity.ActiveAnalysis.PersistSettings.Layout Or GrapeCity.ActiveAnalysis.PersistSettings.DataSource)
C# code. Paste INSIDE the Button Click event. Copy Code System.IO.FileInfo myNewFile = new System.IO.FileInfo(@"C:\MyNew.analysis"); this.pivotView1.Read(myNewFile, GrapeCity.ActiveAnalysis.PersistSettings.Layout | GrapeCity.ActiveAnalysis.PersistSettings.DataSource);