MindFusion.Wpf Pack Programmer's Guide
DeleteCellsForm 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 DeleteCellsForm : Window, INotifyPropertyChanged, IComponentConnector

Visual Basic  Copy Code

Public Class DeleteCellsForm
    Inherits Window
    Implements INotifyPropertyChanged, IComponentConnector

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

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

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

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

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

        }
    }
}

Visual Basic  Copy Code

Dim form = New DeleteCellsForm()
If form.ShowDialog() = True Then

    Using workbook.StartChangeOperation(worksheet)

        Select Case form.Result

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

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

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

            Case CellsFormResult.EntireColumn
                worksheet.Columns.Remove(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.DeleteCellsForm

 See Also

DeleteCellsForm Members
MindFusion.Spreadsheet.Wpf.StandardForms Namespace