Back to Devexpress

SpreadsheetControl.DefinedNameConflictResolving Event

windowsforms-devexpress-dot-xtraspreadsheet-dot-spreadsheetcontrol-8fbb186b.md

latest5.1 KB
Original Source

SpreadsheetControl.DefinedNameConflictResolving Event

Occurs when a formula or sheet being moved or copied contains a defined name that already exists in the destination worksheet or workbook.

Namespace : DevExpress.XtraSpreadsheet

Assembly : DevExpress.XtraSpreadsheet.v25.2.dll

NuGet Package : DevExpress.Win.Spreadsheet

Declaration

csharp
public event DefinedNameConflictResolvingEventHandler DefinedNameConflictResolving
vb
Public Event DefinedNameConflictResolving As DefinedNameConflictResolvingEventHandler

Event Data

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

PropertyDescription
CancelGets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
NameStatusGets the status of the conflict name.
NewNameGets or sets the name for a new version of the defined name being moved or copied.
OldNameGets the defined name for which the event is fired.
UsedNamesProvides access to the set of table and defined names existing in the destination workbook.
UseExistingNameGets or sets a value indicating whether to use the defined name specified on the destination worksheet or workbook in the conflict situation.
ValidatorGets 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 in the destination worksheet or workbook.

The following example demonstrates how to handle the DefinedNameConflictResolving event to always use the defined name specified in the destination worksheet or workbook when names conflict, and suppress displaying the Name Conflict dialog. To do this, set the DefinedNameConflictResolvingEventArgs.UseExistingName and Handled parameters to true.

csharp
spreadsheet.DefinedNameConflictResolving += spreadsheet_DefinedNameConflictResolving;
// ...

private void spreadsheet_DefinedNameConflictResolving(object sender, DefinedNameConflictResolvingEventArgs e)
{
    e.UseExistingName = true;
    e.Handled = true;
}
vb
AddHandler spreadsheet.DefinedNameConflictResolving, AddressOf spreadsheet_DefinedNameConflictResolving
' ...

Private Sub spreadsheet_DefinedNameConflictResolving(ByVal sender As Object, ByVal e As DefinedNameConflictResolvingEventArgs)
  e.UseExistingName = True
  e.Handled = True
End Sub

To create a new version of the defined name being copied, assign the required name to the NewName parameter. The default parameter value is 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 conflicting defined name before pasting it into the destination worksheet/workbook. To specify a custom validator, create an object that implements the IDefinedNameValidator interface and assign it to the DefinedNameConflictResolvingEventArgs.Validator property.

See Also

SpreadsheetControl Class

SpreadsheetControl Members

DevExpress.XtraSpreadsheet Namespace