MindFusion.Wpf Pack Programmer's Guide
InsertWorksheetForm Class
Remarks See Also
 





Prompts the user to insert worksheets within a workbook.

Namespace: MindFusion.Spreadsheet.Wpf.StandardForms
Assembly: MindFusion.Spreadsheet.Wpf.StandardForms

 Syntax

C#  Copy Code

public class InsertWorksheetForm : Window, INotifyPropertyChanged, IComponentConnector

Visual Basic  Copy Code

Public Class InsertWorksheetForm
    Inherits Window
    Implements INotifyPropertyChanged, IComponentConnector

 Remarks

This form can be used to prompt the user to insert new sheets in a workbook. To use the form, create an instance of the InsertWorksheetForm class by providing the related workbook and call the ShowDialog method. The user's choice can be obtained from the Position, Index, NumberOfSheets, and SheetName properties. The following image shows the form:

 Example

The code below demonstrates how to use the form to insert worksheets in an existing workbook. The activeSheet variable identifies the Worksheet that is currently active in the view.

C#  Copy Code

var form = new InsertWorksheetForm(workbook);
if (form.ShowDialog(this) == true)
{
    using (workbook.StartCompositeOperation())
    {
        int index = -1;
        switch (form.Position)
        {

            case InsertWorksheetPosition.AfterActiveSheet:
                index = workbook.Worksheets.IndexOf(activeSheet) + 1;
                break;

            case InsertWorksheetPosition.BeforeActiveSheet:
                index = workbook.Worksheets.IndexOf(activeSheet);
                break;

            case InsertWorksheetPosition.Other:
                index = form.Index;
                break;

        }

        if (form.NumberOfSheets == 1)
        {
            workbook.Worksheets.Insert(index, form.SheetName);
        }
        else
        {
            for (int i = 0; i < form.NumberOfSheets; i++)
                workbook.Worksheets.Insert(index++);
        }
    }
}

Visual Basic  Copy Code

Dim form = New InsertWorksheetForm(workbook)
If form.ShowDialog(Me) = True Then

    Using workbook.StartCompositeOperation()

        Dim index As Integer = -1
        Select Case form.Position

            Case InsertWorksheetPosition.AfterActiveSheet
                index = workbook.Worksheets.IndexOf(activeSheet) + 1
                Exit Select

            Case InsertWorksheetPosition.BeforeActiveSheet
                index = workbook.Worksheets.IndexOf(activeSheet)
                Exit Select

            Case InsertWorksheetPosition.Other
                index = form.Index
                Exit Select

        End Select

        If form.NumberOfSheets = 1 Then
            workbook.Worksheets.Insert(index, form.SheetName)
        Else
            For i As Integer = 0 To form.NumberOfSheets - 1
                workbook.Worksheets.Insert(index)
                index = index + 1
            Next
        End If

    End Using

End If

 Inheritance Hierarchy

System.Object
    System.Windows.Threading.DispatcherObject
        System.Windows.DependencyObject
            System.Windows.Media.Visual
                System.Windows.UIElement
                    System.Windows.FrameworkElement
                        System.Windows.Controls.Control
                            System.Windows.Controls.ContentControl
                                System.Windows.Window
                                    MindFusion.Spreadsheet.Wpf.StandardForms.InsertWorksheetForm

 See Also

InsertWorksheetForm Members
MindFusion.Spreadsheet.Wpf.StandardForms Namespace