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





Prompts the user to insert cells within a worksheet.

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

 Syntax

C#  Copy Code

public class InsertCellsForm : Window, INotifyPropertyChanged, IComponentConnector

Visual Basic  Copy Code

Public Class InsertCellsForm
    Inherits Window
    Implements INotifyPropertyChanged, IComponentConnector

 Remarks

This form can be used to prompt the user to insert cells in a worksheet. To use the form, create an instance of the InsertCellsForm class and call the ShowDialog method. The user's choice can be obtained from the Result property. The following image shows the form:

 Example

The code below demonstrates how to use the form to insert cells in an existing cell range.

C#  Copy Code

var form = new InsertCellsForm();
if (form.ShowDialog() == true)
{
    using (workbook.StartChangeOperation(worksheet))
    {
        switch (form.Result)
        {

            case CellsFormResult.ShiftVertical:
                cellRange.Insert(PushDirection.Down);
                break;

            case CellsFormResult.ShiftHorizontal:
                 cellRange.Insert(PushDirection.Right);
                 break;

            case CellsFormResult.EntireRow:
                 worksheet.Rows.Insert(cellRange.Top, 1 + Math.Abs(cellRange.Top - cellRange.Bottom));
                 break;

            case CellsFormResult.EntireColumn:
                 worksheet.Columns.Insert(cellRange.Left, 1 + Math.Abs(cellRange.Right - cellRange.Left));
                 break;

        }
    }
}

Visual Basic  Copy Code

Dim form = New InsertCellsForm()
If form.ShowDialog() = DialogResult.OK Then

    Using workbook.StartChangeOperation(worksheet)

        Select Case form.Result
            Case CellsFormResult.ShiftVertical
                cellRange.Insert(PushDirection.Down)
                Exit Select
            Case CellsFormResult.ShiftHorizontal
                cellRange.Insert(PushDirection.Right)
                Exit Select
            Case CellsFormResult.EntireRow
                worksheet.Rows.Insert(cellRange.Top, 1 + Math.Abs(cellRange.Top - cellRange.Bottom))
                Exit Select
            Case CellsFormResult.EntireColumn
                worksheet.Columns.Insert(cellRange.Left, 1 + Math.Abs(cellRange.Right - cellRange.Left))
                Exit Select
        End Select

    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.InsertCellsForm

 See Also

InsertCellsForm Members
MindFusion.Spreadsheet.Wpf.StandardForms Namespace