Occurs before nodes are pasted from the clipboard.
Syntax
Example
The following sample code illustrates some of the information available in the BeforePaste event.
For an overview of how to handle events in Visual Basic or Visual C#, see
Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see
Consuming Events in the
.NET Framework Developer's Guide.
| Visual Basic | Copy Code |
|---|
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
If e.Nodes.Tag <> Me.ultraTree1.GetHashCode() Then
e.Cancel = True
Exit Sub
End If
e.ParentNode = Nothing
e.Index = 0
End Sub
|
| C# | Copy Code |
|---|
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;
} |
See Also