SpreadsheetControl.DefinedNameConflictResolving Event
Occurs when a formula or sheet being moved or copied contains a defined name which already exists on the destination worksheet or workbook.
Namespace: DevExpress.Xpf.Spreadsheet
Assembly: DevExpress.Xpf.Spreadsheet.v24.1.dll
NuGet Package: DevExpress.Wpf.Spreadsheet
Declaration
Event Data
The DefinedNameConflictResolving event's data class is DefinedNameConflictResolvingEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cancel | Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs. |
NameStatus | Gets the status of the conflict name. |
NewName | Gets or sets the name for a new version of the defined name being moved or copied. |
OldName | Gets the defined name for which the event is fired. |
UsedNames | Provides access to the set of table and defined names existing in the destination workbook. |
UseExistingName | Gets or sets a value indicating whether to use the defined name specified on the destination worksheet or workbook in the conflict situation. |
Validator | Gets or sets a validator used to check whether a new version of the conflict name is valid and unique. |
Remarks
Use the DefinedNameConflictResolving event to handle a name conflict error which occurs when a copied name already exists on the destination worksheet or workbook.
The following example demonstrates how to handle the DefinedNameConflictResolving event to always use the defined name specified on the destination worksheet or workbook in the conflict situation and suppress displaying the Name Conflict dialog. To do this, set the DefinedNameConflictResolvingEventArgs.UseExistingName and Handled parameters to true.
spreadsheet.DefinedNameConflictResolving += spreadsheet_DefinedNameConflictResolving;
// ...
private void spreadsheet_DefinedNameConflictResolving(object sender, DefinedNameConflictResolvingEventArgs e)
{
e.UseExistingName = true;
e.Handled = true;
}
To create a new version of the defined name being copied, assign the necessary name to the DefinedNameConflictResolvingEventArgs.NewName parameter. By default, it already contains an automatically generated defined name you can use or modify.
The DefinedNameConflictResolvingEventArgs.Validator parameter provides access to the default validator that enables you to validate a new version of the conflict defined name before pasting it into the destination worksheet/workbook. To specify a custom validator, create an object implementing the IDefinedNameValidator interface and assign it to the DefinedNameConflictResolvingEventArgs.Validator property.