A newer version of this page is available. Switch to the current version.

VGridControlBase.CustomizationFormDeletingCategory Event

Fires when an end-user tries to delete a category row from the Customization Form.

Namespace: DevExpress.XtraVerticalGrid

Assembly: DevExpress.XtraVerticalGrid.v18.2.dll

Declaration

public event CustomizationFormDeletingCategoryEventHandler CustomizationFormDeletingCategory

Event Data

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

Property Description
CanDelete Gets or sets a value specifying whether a row is allowed to be deleted.
Category Gets the processed category row. Inherited from CategoryEventArgs.

Remarks

Customization allows end-users to create new category rows and delete category rows that are displayed within the Customization Form. To delete a category row, an end-user should select the required row within the Categories page of the Customization Form and click the Delete button.

The CustomizationFormDeletingCategory event is raised immediately after the Delete button has been clicked and before the category row is actually deleted. This event enables the row’s deletion to be canceled. The event parameter provides the CustomizationFormDeletingCategoryEventArgs.CanDelete property that control whether the category row can be deleted. The processed category row is returned by the CategoryEventArgs.Category property.

If the CustomizationFormDeletingCategoryEventArgs.CanDelete property is set to true, the category row disappears from the Customization Form. This means that the row has been successfully deleted and no longer belongs to any row collection within the vertical grid. If the deleted row was a parent row, its children are then processed based on the VGridOptionsBehavior.PreserveChildRows option setting:

  • if this option is set to false, the child rows are deleted as well;
  • if this option is set to true, the child rows are hidden and moved to the VGridControlBase.Rows collection that represents top-level grid rows (root collection).

Examples

This example demonstrates how to handle the VGridControlBase.CustomizationFormDeletingCategory event to check whether the category row selected for deletion contains a specific row (namely the Icon row used for displaying car pictures). If so, a notification message is displayed and deletion of the category row is prohibited by setting the CanDelete property to false.

using DevExpress.XtraVerticalGrid.Events;

private void vGridControl1_CustomizationFormDeletingCategory(object sender, 
CustomizationFormDeletingCategoryEventArgs e) {
    if (vGridControl1.Rows["row_Icon"] == null) return;
    BaseRow iconRow = vGridControl1.Rows["row_Icon"];
    // checking whether the deleted category row contains the specified Icon row
    if (e.Category.HasAsChild(iconRow)) {
        string messageText = 
        "You cannot delete this category, " + _ 
        "since it contains the Icon row obligatory for display purpose.";
        // displaying a notify message
        MessageBox.Show(messageText,"Denied Operation");
        // prohibiting row deletion
        e.CanDelete = false;
    }
}
See Also