Search
DeleteCellsForm Class
Remarks See Also
 






Prompts the user to delete cells from a worksheet.

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

 Syntax

C#  Copy Code

public class DeleteCellsForm : Form

Visual Basic  Copy Code

Public Class DeleteCellsForm
    Inherits Form

 Remarks

This form can be used to prompt the user to delete cells from a worksheet. To use the form, create an instance of the DeleteCellsForm 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 delete cells in an existing cell range.

C#  Copy Code

var form = new DeleteCellsForm();
if (form.ShowDialog() == DialogResult.OK)
{
    using (workbook.StartChangeOperation(worksheet))
    {
        switch (form.Result)
        {

            case CellsFormDialogResult.ShiftVertical:
                cellRange.Remove(ShiftDirection.Up);
                break;

            case CellsFormDialogResult.ShiftHorizontal:
                 cellRange.Remove(ShiftDirection.Left);
                 break;

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

            case CellsFormDialogResult.EntireColumn:
                 cellRange.Columns.Remove(cellRange.Left, 1 + Math.Abs(cellRange.Right - cellRange.Left));
                 break;

        }
    }
}

Visual Basic  Copy Code

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

    Using workbook.StartChangeOperation(worksheet)

        Select Case form.Result

            Case CellsFormDialogResult.ShiftVertical
                cellRange.Remove(ShiftDirection.Up)
                Exit Select

            Case CellsFormDialogResult.ShiftHorizontal
                cellRange.Remove(ShiftDirection.Left)
                Exit Select

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

            Case CellsFormDialogResult.EntireColumn
                cellRange.Columns.Remove(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.DeleteCellsForm

 See Also