Back to Devexpress

VGridControlBase.CustomizationFormDeletingCategory Event

windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridcontrolbase-80a2f314.md

latest5.0 KB
Original Source

VGridControlBase.CustomizationFormDeletingCategory Event

Fires when a category is about to be deleted in Customization Form.

Namespace : DevExpress.XtraVerticalGrid

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid

Declaration

csharp
public event CustomizationFormDeletingCategoryEventHandler CustomizationFormDeletingCategory
vb
Public Event CustomizationFormDeletingCategory As CustomizationFormDeletingCategoryEventHandler

Event Data

The CustomizationFormDeletingCategory event's data class is CustomizationFormDeletingCategoryEventArgs. The following properties provide information specific to this event:

PropertyDescription
CanDeleteGets or sets a value specifying whether a row is allowed to be deleted.
CategoryGets the processed category row. Inherited from CategoryEventArgs.

Remarks

To delete a category in Customization Form , select the category in the Categories page and click Delete.

The CustomizationFormDeletingCategory event fires after Delete button is clicked and before the category is deleted.

The Category event parameter returns the category that is about to be deleted. Set the CanDelete event parameter to false to cancel the action.

When a user deletes a category, its rows are also deleted. The VGridControl.OptionsBehavior.PreserveChildRows property allows you to preserve the rows, and delete the category only. The preserved rows move to the root level.

Example

This code below shows how to check whether the category that is about to be deleted contains a specific row. If the category contains the specified row, the code cancels the action and shows a notification.

csharp
using DevExpress.XtraVerticalGrid.Events;

private void vGridControl1_CustomizationFormDeletingCategory(object sender, 
CustomizationFormDeletingCategoryEventArgs e) {
    VGridControl vGridControl = sender as VGridControl;
    BaseRow iconRow = vGridControl.Rows["erPhoto"];
    if (iconRow == null) return;
    // Check whether the category contains the specified row.
    if (e.Category.HasAsChild(iconRow)) {
        string messageText = 
        "You cannot delete this category.";
        // Display a notification.
        MessageBox.Show(messageText,"Denied Operation");
        // Cancel the action.
        e.CanDelete = false;
    }
}
vb
Imports DevExpress.XtraVerticalGrid.Events

Private Sub VGridControl1_CustomizationFormDeletingCategory(ByVal sender As Object, _
ByVal e As CustomizationFormDeletingCategoryEventArgs) _
Handles VGridControl1.CustomizationFormDeletingCategory
    Dim vGridControl As VGridControl = TryCast(sender, VGridControl)
    Dim iconRow As BaseRow = vGridControl.Rows("erPhoto")
    If iconRow Is Nothing Then
        Return
    End If
    ' Check whether the category contains the specified row.
    If e.Category.HasAsChild(iconRow) Then
        Dim messageText As String = "You cannot delete this category."
        ' Display a notification.
        MessageBox.Show(messageText, "Denied Operation")
        ' Cancel the action.
        e.CanDelete = False
    End If
End Sub

See Also

CustomizationFormCreatingCategory

VGridControlBase Class

VGridControlBase Members

DevExpress.XtraVerticalGrid Namespace