ComponentOne FlexPivot for WinForms
Task-Based Help / Creating Custom FlexPivot Application in Code / Persisting Views
In This Topic
    Persisting Views
    In This Topic

    Users can also persist the view they created in their FlexPivot application across session. Any customization made by the user on the view can be saved and restored when the application is run next time.

    To persist views, perform the following steps.

    1. Add the following code to save the current view by reading the ViewDefinition property and assigning it to the DefaultView created.
      Protected Overrides Sub OnClosing(e As CancelEventArgs)
          'save current view as new default
          My.Settings.DefaultView = FlexPivotPage1.ViewDefinition
          My.MySettings.Default.Save()
          MyBase.OnClosing(e)
      End Sub
      
      // saves current view as default for next time when the form closes
      protected override void OnClosing(CancelEventArgs e)
      {
          // save current view as new default
          Properties.Settings.Default.DefaultView = flexPivotPage1.ViewDefinition;
          Properties.Settings.Default.Save();
          base.OnClosing(e);
      }
      
    2. Press F5 to run the application and drag City data field in the Rows list. The default view appears similar to the image below.

      persisting_views     

    3. Close the application and restart it by pressing F5. The last view that you created persists and appears as the default view.