Table Tree Event: DuplicatedKey 

Purpose

Event-notification that an already-existing key is being inserted or assigned.

Syntax

The DuplicatedKey event-handler has the syntax:

void DuplicatedKey(Object Node, String *NewKey,

String OldKey, Short *Handled)

Parameters

Description

This event is fired after the user tries to:

There are several possible reactions to the DuplicatedKey event. Your event-handler could remove the Node by invoking the node’s Remove method. Or the handler could change the node’s Key property to a new value (by returning the new value in the parameter NewKey). However, you may not modify the Key property of the Node object. This would not lead to any change of the key.

In any case, you must set the Handled flag to TRUE to inform the control that the event has been handled. If you don’t do this, an exception is raised. You can also return an empty string in NewKey. This removes the node from the key map but not from the control. Afterwards, the node is not accessible via keys anymore, until a valid key is assigned. If the event-handling routine provides a new key that already exists, a further DuplicatedKey event is fired.

Improper handling of the DuplicatedKey event may lead to an endless loop. This would be the case if no valid key is provided and the Handled flag is set to TRUE.