HierarchyInfo.OnDeleting(CancelEventArgs) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs when the Delete() method is called from the user interface (UI) or programmatically.
protected:
virtual void OnDeleting(System::ComponentModel::CancelEventArgs ^ e);
protected virtual void OnDeleting (System.ComponentModel.CancelEventArgs e);
abstract member OnDeleting : System.ComponentModel.CancelEventArgs -> unit
override this.OnDeleting : System.ComponentModel.CancelEventArgs -> unit
Protected Overridable Sub OnDeleting (e As CancelEventArgs)
Parameters
A CancelEventArgs that contains the event data.
Examples
The following example will cancel the Delete method based on a random Boolean value.
public bool DemoDelete()
{
bool bCancel = SH.nextRandBool();
Trace.WriteLine("OnDeleting called on " + Text +
" at " + System.DateTime.Now.ToString()
+ " Cancel Delete = " + bCancel.ToString());
return bCancel; // return cancel choice
}
protected override void OnDeleting(System.ComponentModel.CancelEventArgs e)
{
e.Cancel = !DemoDelete();
}
Remarks
If the application supports deleting, call your application-specific Delete
method here. Setting the <xref:System.ComponentModel.CancelEventArgsCancel?displayProperty=fullName> property to false
will prevent the Delete method from being called and the node will not be removed from the UI tree.