The event handler receives an argument of type CustomizationFormDeletingCategoryEventArgs containing data related to this event.
The following
CustomizationFormDeletingCategoryEventArgs 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. |
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 CategoryEventArgs.Category event parameter returns the category that is about to be deleted. Set the CustomizationFormDeletingCategoryEventArgs.CanDelete event parameter to false
to cancel the action.
When a user deletes a category, its rows are also deleted. The VGridOptionsBehavior.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.

C# |
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;
if (e.Category.HasAsChild(iconRow)) {
string messageText =
"You cannot delete this category.";
MessageBox.Show(messageText,"Denied Operation");
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
If e.Category.HasAsChild(iconRow) Then
Dim messageText As String = "You cannot delete this category."
MessageBox.Show(messageText, "Denied Operation")
e.CanDelete = False
End If
End Sub
|