Search
InsertCellsForm Class
Remarks See Also
 






Prompts the user to insert cells within a worksheet.

Namespace: MindFusion.Spreadsheet.WinForms
Assembly: MindFusion.Spreadsheet.WinForms.StandardForms

 Syntax

C#  Copy Code

public class InsertCellsForm : Form

Visual Basic  Copy Code

Public Class InsertCellsForm
    Inherits Form

 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() == DialogResult.OK)
{
    using (workbook.StartChangeOperation(worksheet))
    {
        switch (form.Result)
        {

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

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

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

            case CellsFormDialogResult.EntireColumn:
                 cellRange.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 CellsFormDialogResult.ShiftVertical
                cellRange.Insert(PushDirection.Down)
                Exit Select

            Case CellsFormDialogResult.ShiftHorizontal
                cellRange.Insert(PushDirection.Right)
                Exit Select

            Case CellsFormDialogResult.EntireRow
                cellRange.Rows.Insert(cellRange.Top, 1 + Math.Abs(cellRange.Top - cellRange.Bottom))
                Exit Select

            Case CellsFormDialogResult.EntireColumn
                cellRange.Columns.Insert(cellRange.Left, 1 + Math.Abs(cellRange.Right - cellRange.Left))
                Exit Select

        End Select

    End Using

End If

 Inheritance Hierarchy

System.Object
    System.MarshalByRefObject
        System.ComponentModel.Component
            System.Windows.Forms.Control
                System.Windows.Forms.ScrollableControl
                    System.Windows.Forms.ContainerControl
                        System.Windows.Forms.Form
                            MindFusion.Spreadsheet.WinForms.InsertCellsForm

 See Also