'宣言 Protected Overridable Sub OnBeforePaste( _ ByVal e As BeforePasteEventArgs _ )
protected virtual void OnBeforePaste( BeforePasteEventArgs e )
Imports Infragistics.Win Imports Infragistics.Win.UltraWinTree Private Sub ultraTree1_BeforePaste(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTree.BeforePasteEventArgs) Handles ultraTree1.BeforePaste Dim sb As New System.Text.StringBuilder() Dim node As UltraTreeNode Dim dr As DialogResult ' Setting the Tag of the Nodes collection passed into the BeforeCut ' and BeforeCopy events to some serializable value can be used to ' identify the tree that copied the nodes to the clipboard. This Tag ' value will be de-serialized and set on the Nodes collection that is ' passed into the BeforePaste event. This can be used for preventing ' paste operations between trees. ' If these nodes weren't copied from this tree then cancel the paste If e.Nodes.Tag <> Me.ultraTree1.GetHashCode() Then e.Cancel = True Exit Sub End If ' Note: The BeforePaste event will be raised even if there are no ' nodes on the clipboard. This is done to allow other clipboard formats ' to be checked. ' The ParentNode property can be changed to specify where the ' pasted nodes will go. A value of Nothing will make them root nodes. e.ParentNode = Nothing ' Setting the index property will cause the nodes to be pasted ' in the parent's Nodes collection at that index. In this case ' setting the index to 0 will paste the nodes before any other ' nodes in the collection. e.Index = 0 End Sub
using System.Diagnostics; using Infragistics.Win; using Infragistics.Win.UltraWinTree; private void ultraTree1_BeforePaste(object sender, Infragistics.Win.UltraWinTree.BeforePasteEventArgs e) { // Setting the Tag of the Nodes collection passed into the BeforeCut // and BeforeCopy events to some serializable value can be used to // identify the tree that copied the nodes to the clipboard. This Tag // value will be de-serialized and set on the Nodes collection that is // passed into the BeforePaste event. This can be used for preventing // paste operations between trees. // If these nodes weren't copied from this tree then cancel the paste if ( (int)e.Nodes.Tag != this.ultraTree1.GetHashCode() ) { e.Cancel = true; return; } // Note: The BeforePaste event will be raised even if there are no // nodes on the clipboard. This is done to allow other clipboard formats // to be checked. // The ParentNode property can be changed to specify where the // pasted nodes will go. A value of null will make them root nodes. e.ParentNode = null; // Setting the index property will cause the nodes to be pasted // in the parent's Nodes collection at that index. In this case // setting the index to 0 will paste the nodes before any other // nodes in the collection. e.Index = 0; }